pnp / pnpassessment

Microsoft 365 SharePoint Assessment tool enabling various deprecation and adoption scenarios
https://aka.ms/microsoft365assessmenttool
MIT License
28 stars 14 forks source link

Max page size error when running Add-In and ACS Assessment #39

Closed ArturoAP closed 8 months ago

ArturoAP commented 8 months ago

Hi, we're facing an issue when attempting to run Assessment tool in Add-Ins and ACS mode, previously we had a similar Graph Exception issue thrown by missing permissions on delegated user, however this time the error seems to be a different cause stating Bad Request where Max Page should be equal or less than 501.

We're running version 1.6.0 on Windows 10

2024-02-07 18:02:06.890 -05:00 [INF] End processing HTTP request after 355.5699ms - 200 
2024-02-07 18:02:07.000 -05:00 [INF] Start processing HTTP request GET "https://tenant.sharepoint.com/api/Site/$select-Id%2cGroupId"
2024-02-07 18:02:07.001 -05:00 [INF] Sending HTTP request GET https://tenant.sharepoint.com/_api/Site/$select-Id%2cGroupId
2024-02-07 18:02:07.123 -05:00 [INF] Received HTTP response headers after 122.0903ms - 200
2024-02-07 18:02:07.123 -05:00 [INF] End processing HTTP request after 122.4234ms - 200
2024-02-07 18:02:07.131 -05:00 [INF] Vanity URLs passed in: my site host and tenant admin
2024-02-07 18:02:07.229 -05:00 [INF] Start processing HTTP request GET https://graph.microsoft.com/v1.0/me/memberOf?$count=true&$search=\"displayName: Company Administrator\" OR \"displayName: Global Administrator\"
2024-02-07 18:02:07.220 -05:00 [INF] Sending HTTP request GET "https://graph.microsoft.com/v1.0/me/memberOf?$count=true?$search=\"displayName: Company Administrator\" OR \"displayName: Global Administrator\"
2024-02-07 18:02:07.700 -05:00 [INF] Received HTTP response headers after 551.6501 - 200
2024-02-07 18:02:07.781 -05:00 [INF] End processing HTTP request after 551.9481ms - 200
2024-02-07 18:02:07.799 -05:00 [INF] Start processing HTTP request POST "https://graph.microsoft.com/v1.0/search/query"
2024-02-07 18:02:07.799 -05:00 [INF] Sending HTTP request POST "https://graph.microsoft.com/v1.0/search/query 
2024-02-07 18:02:10.926 -05:00 [INF] Received HTTP response headers after 3126.5674ms - 200
2024-02-07 18:02:10.926 -05:00 [INF] End processing HTTP request after 3126.8386ms - 200 
2024-02-07 18:02:10.948 -05:00 [INF] Start processing HTTP request POST "https://graph.microsoft.com/v1.0/search/query
2024-02-07 18:02:10.948 -05:00 [INF] Sending HTTP request POST "https://graph.microsoft.com/v1.0/search/query 
2024-02-07 18:02:11.126 -05:00 [INF] Received HTTP response headers after 178.0127ms - 400
2024-02-07 18:02:11.126 -05:00 [INF] End processing HTTP request after 178.3536ms - 400 
2024-02-07 18:02:11.137 -05:00 [ERR] Error starting assessment job: Microsoft Graph service exception
HttpResponseCode: 400
Code: BadRequest
Message: SearchRequest Invalid (Max page size should be <= 501.)
ClientRequestId:
target:
details: [{"code":"Microsoft.SubstrateSearch.Api.ErrorReporting.ResourceBasedExceptions.BadRequestException", "message": "Max page size should be <= 501.", "target":"","httpCode":400}]
httpCode: 400

PnP.Core.MicrosoftGraphServiceException: Microsoft Graph service exception 
    at PnP.Core.Services.BatchClient.ExecuteMicrosoftGraphInteractiveAsync(Batch batch)
    at PnP.Core.Services.BatchClient.ExecuteMicrosoftGraphBatchAsync(Batch batch)
    at PnP.Core.Services.BatchClient.ExecuteBatch(Batch batch)
    at PnP.Core.Model.BaseDataModel`1. RequestAsync(Apicall apicall, HttpMethod method, String operationName)
    at PnP.Core.Model.BaseDataModel`1. RawRequestAsync(Apicall apicall, HttpMethod method, String operationName)
    at PnP.Core.Admin.Model.SharePoint.SiteCollectionEnumerator.GetViagraphSearchApAsync(PnPContext context, VanityUrlOptions vanityUrloptions, SiteCollectionFilter filter, Int32 pagesize)
    at PnP.Core.Admin.Model.SharePoint.SiteCollectionEnumerator.GetAsync(PPContext context, VanityUrloptions vanityUrloptions, Boolean ignoreUserIsTenantAdmin, SiteCollectionFilter Filter)
    at PnP.Core.Admin.Model.SharePoint.SiteCollectionManager.GetSiteCollectionsAsync(Boolean ignoretUserIsSharePointAdmin, SiteCollectionFilter filter, VanityUrloptions vanitytUrlOptions)
    at PnP.Scanning.Core.Services.SiteEnumerationManager.EnumerateSiteCollectionsToScanAsync(StartRequest start, AuthenticationManager authentication/Manager, Action 1 feedback)
    at PnP.Scanning.Core.Services.Scanner.Start(StartRequest request, IServerStreamWriter`1 responseStream, ServerCallContext context)
2024-02-07 18:02:11.105 -05:00 [INF] Executed endpoint 'gRPC/PnP.Scanning.Core.Services.PrPScanner/Start
2024-02-07 18:02:11.166 -05:00 [INF] Request finished HTTP/2 POST http://localhost:25818/PnP.Scanning.Core.Services.PnPScanner/Start application/grpc - - 200 - application/grpc 5408.8682ms
jansenbe commented 8 months ago

@ArturoAP : that's weird as the page size we're setting is 500. Can you do a Fiddler trace and send the result to bjansen@microsoft.com?

As a way around, I would recommend using application permissions as that will allow you to assess the whole tenant. The "search" option that fails is used to enumerate the site collections to scan when using delegated permissions (e.g. interactive). Alternative workaround is specifying the sites to assess yourselves via a sites file (see https://pnp.github.io/pnpassessment/using-the-assessment-tool/assess-start.html#scoping-via---siteslist)

ArturoAP commented 8 months ago

Sorry we're not allowed to use these kinds of tools, however we did workaround it by running the assessment in batches of 500 sites via list file as suggested, while running it we did found one of the batches failed on a specific site so it's possible this was causing the issue.