Repository navigation
fix(files): fail fast with a clear message when Microsoft throttles the certificate pre-flight check - #209
Merged
Conversation
…he certificate pre-flight check The certificate authentication pre-flight used a session Retry policy that honoured uncapped Retry-After headers on 429, so throttled tenants appeared to hang for ~50 minutes at 'Verifying certificate authentication'. - Override the pre-flight session retry policy (2 retries on 500/502/504, Retry-After ignored). - Detect HTTP 429/503 on Graph/SharePoint responses and in wrapped token errors and raise ThrottledError. - Show a dedicated Retry/Cancel dialog with the Retry-After time; log status, stage, error codes and request IDs. - Word 503 as 'throttling or service busy'. - Replace the misleading 'authenticated and verified' log with scope-aware sign-in wording. - Add 7 unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some tenants appeared stuck at "Verifying certificate authentication" in the Files planner even though their certificates and secrets were valid.
Root cause: Microsoft was throttling SharePoint for the app (Graph
GET /sites/root→429,Retry-After: 300,activityLimitReached > throttledRequest > forbiddenQuota). The pre-flight session's urllib3Retrypolicy honoured the uncappedRetry-Afterheader, so the check silently retried for up to ~50 minutes (10 × 300 s).The log line
App xxxxx... authenticated and verified.was also misleading: it was printed before any SharePoint access had been checked.Changes
util/constants.py: addTHROTTLING_STATUS_CODES = (429, 503)as the single list of throttling codes.ui/files_shallow/shallow_ui_helpers.pyrespect_retry_after_header=False. 429/503 are no longer retried silently.ThrottledError, which carries the status, Retry-After, stage, diagnostics (Graph/SP inner error codes, AADSTS codes, request IDs) and the local retry time.__cause__/__context__chain).util/files_shallow/cert_token_manager.py: a throttled certificate token request gets a throttling-specific message instead of the misleading "ensure certificate.pem is uploaded" advice.util/auth_manager.py: replace "authenticated and verified" with wording that matches what was actually checked:signed in; required API permissions confirmed.when required scopes were checkedsigned in (access token issued).otherwiseNot in scope
SpRestConnectoralready caps waits at 30 s).Testing
python3 -m unittest tests.files.shallow_estimator_test: 68/68 pass (7 new tests for 429, 503, throttling found inside a token error, missing Retry-After, non-throttling errors, HTTP-date Retry-After, and the retry policy).