Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with SiteCollectionManager.GetSiteCollectionWithDetailsAsync - returns null when getting root site collection #1089

Closed
mjonila opened this issue Feb 8, 2023 · 2 comments
Assignees
Labels
area:admin 📜 Admin library related bug Something isn't working

Comments

@mjonila
Copy link

mjonila commented Feb 8, 2023

There is a problem with SiteCollectionManager.GetSiteCollectionWithDetailsAsync as it is always returning null for root site collection. I debugged the code and found out that internally it is calling

SiteCollectionEnumerator.GetWithDetailsViaTenantAdminHiddenListAsync(PnPContext context, Uri url, VanityUrlOptions vanityUrlOptions)

which tries to get site collection passing CAML query to hidden list in tenant admin site.
However the query is not properly formatted when working with root site collection. For instance:

var hubSite = await Ctx.GetSiteCollectionManager.GetSiteCollectionWithDetailsAsync(new Uri("https://contoso.sharepoint.com"));

queries for https://contoso.sharepoint.com/ (note final "/"), but not the original Uri.

This does not return any results from the list and return null.

GetWithDetailsViaTenantAdminHiddenListAsync method is using url parameter which is passed as url.AbsoluteUri to the CAML query.
Instead it should be url.OriginalString or final "/" be removed.

@jansenbe jansenbe added bug Something isn't working area:admin 📜 Admin library related labels Feb 8, 2023
jansenbe added a commit that referenced this issue Feb 9, 2023
@jansenbe
Copy link
Contributor

jansenbe commented Feb 9, 2023

@mjonila : thanks for using PnP Core SDK and reporting this issue, I've implemented a fix which will be included in our next nightly build (version 1.8.96 or higher). Closing this issue now, please re-open if you still have issues when testing with the next nightly

@jansenbe jansenbe closed this as completed Feb 9, 2023
@jansenbe jansenbe self-assigned this Feb 9, 2023
@Breathtaker
Copy link

Bug still exists in PnP.Core.Admin 1.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:admin 📜 Admin library related bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants