Skip to content

perf(files): fix REST maxUrlLength 401 on deep subsites and optimize batch plan generation - #183

Merged
NityamPareek merged 1 commit into
files-shallow-scanfrom
perf/shallow-url-length-and-batching
Sep 22, 2026
Merged

NityamPareek merged 1 commit into
files-shallow-scanfrom
perf/shallow-url-length-and-batching

Conversation

@NityamPareek

Copy link
Copy Markdown
Collaborator

Summary

Fixes two issues observed on large tenants (~35,800 Document Libraries, deeply nested 9-12 level subsites):

  1. Eliminates maxUrlLength 401 failures on deeply nested subsites (346 failed drives -> 0):

    • Previously, the SharePoint REST connector embedded the full server-relative library path directly inside the URL path segment (GetList('/sites/...') and GetFolderByServerRelativeUrl('/sites/...')), repeating the 9-12 level subsite path twice in the URL path (~395-486 chars) and exceeding ASP.NET's 260-character maxUrlLength limit on Request.Path.
    • Passes the library relative path via the OData query parameter alias @v (GetList(@v)?@v='...' and GetFolderByServerRelativeUrl(@v)?@v='...'), moving the ~200-character library path into the query string (maxQueryStringLength >= 2048 bytes).
    • For ultra-deep subsites (12+ levels where base_url path >= 218 chars) where GetFolderByServerRelativeUrl(@v) would still reach 260 chars, addresses the folder via GetList(@v)/RootFolder (10 chars shorter in the URL path, identical JSON response).
    • Fails fast on non-auth 401 responses containing maxUrlLength or Runtime Error instead of triggering 5 redundant certificate token refreshes.
  2. Optimizes Migration Plan / Batch Generation (~72 minutes -> ~3.1 seconds on 35,000 sites):

    • Precomputes single-site ETAs once per site instead of reconstructing single-row DataFrames 80 times across all (target_hours, lanes) candidates.
    • Precomputes greedy lane assignments and interleaved lane tables once per lane count (1..5) instead of repeating across all 16 candidate_hours.
    • Replaces row-by-row DataFrame iteration on every binary-search probe with direct sums over pre-extracted lists in the exact same addition order.
    • Populates the Suggested Batch column once on the selected plan in O(N) instead of running an O(N^2) boolean lookup across all 80 candidate iterations.

Verification

  • All existing unit test suites pass (Ran 64 tests in 2.067s - OK).
  • Verified 100% bit-for-bit equivalence of all 80 candidate evaluations, final DataFrame, batch definitions, and ETAs against the previous implementation.
  • Verified URL path lengths < 260 characters across all 9-12 level subsite URLs from the tenant logs.
@NityamPareek
NityamPareek merged commit 7b967ec into files-shallow-scan Sep 22, 2026
1 check passed
@NityamPareek
NityamPareek deleted the perf/shallow-url-length-and-batching branch September 22, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants