Skip to content

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

@mjonila

Description

@mjonila

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.

Metadata

Metadata

Assignees

Labels

area:admin 📜Admin library relatedbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions