Keep Nango error bodies so expired Outlook tokens reconnect - #7153
Merged
Conversation
error_for_status dropped the Graph/Nango body, so expired-token failures looked like generic 500s and never persisted reconnect_required.
✅ Deploy Preview for anarlog canceled.
|
Retries: 3 turns Graph 401s into a 21s 500. Calendar list calls now fail on the first 401 so we can mark reconnect immediately.
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.
Summary
Problem: 0.0.78 still returned 500 on Outlook list-events (~21s). Nango exhausts 401 retries and responds 500;
error_for_statusdiscarded the body, so we never sawInvalidAuthenticationToken/invalid_credentialsand never marked reconnect.Fix: Proxy errors now include status + body. Auth detection also matches Nango refresh failures (
invalid_credentials, could not refresh). Generic 500s stay 500s.Verification
cargo test -p nango --libcargo test -p api-nango --lib detects_graph_expired_tokenNote
Medium Risk
Changes Nango proxy error handling and calendar auth-failure detection for all Google/Outlook list routes; misclassification could wrongly trigger reconnect or still return 500, but scope is limited to integration HTTP clients with added tests.
Overview
Fixes calendar list endpoints returning slow 500 responses instead of 424 reconnect when Nango/Graph auth fails after retries.
Nango HTTP layer: Proxy responses no longer use
error_for_status(), which dropped error bodies. Failed responses are read viaresponse_bytesand surfaced asError::Api(status, body)so downstream code can inspect provider/Nango payloads (including 500 responses that still carry auth JSON).Auth classification:
is_provider_auth_failurenow matches additional message shapes (status 401,invalid_credentials, refresh-token failures) somap_provider_errorcan mark connections reconnect-required instead of treating them as generic internal errors.Calendar routes: Google and Outlook list-calendars/list-events HTTP clients call
with_retries(0)to avoid long Nango retry loops on bad tokens (~21s) while still benefiting from preserved error bodies.Reviewed by Cursor Bugbot for commit 6b91f2b. Bugbot is set up for automated code reviews on this repo. Configure here.