Skip to content

Keep Nango error bodies so expired Outlook tokens reconnect - #7153

Merged
ComputelessComputer merged 2 commits into
mainfrom
fix/outlook-nango-500-body
Aug 29, 2026
Merged

Keep Nango error bodies so expired Outlook tokens reconnect#7153
ComputelessComputer merged 2 commits into
mainfrom
fix/outlook-nango-500-body

Conversation

@ComputelessComputer

@ComputelessComputer ComputelessComputer commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Problem: 0.0.78 still returned 500 on Outlook list-events (~21s). Nango exhausts 401 retries and responds 500; error_for_status discarded the body, so we never saw InvalidAuthenticationToken / invalid_credentials and 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 --lib
  • cargo test -p api-nango --lib detects_graph_expired_token

Note

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 via response_bytes and surfaced as Error::Api(status, body) so downstream code can inspect provider/Nango payloads (including 500 responses that still carry auth JSON).

Auth classification: is_provider_auth_failure now matches additional message shapes (status 401, invalid_credentials, refresh-token failures) so map_provider_error can 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.

error_for_status dropped the Graph/Nango body, so expired-token failures looked like generic 500s and never persisted reconnect_required.
@netlify

netlify Bot commented Aug 29, 2026

Copy link
Copy Markdown

Deploy Preview for anarlog canceled.

Name Link
🔨 Latest commit 6b91f2b
🔍 Latest deploy log https://app.netlify.com/projects/anarlog/deploys/6a92ba67a2fce6000886534c

Retries: 3 turns Graph 401s into a 21s 500. Calendar list calls now fail on the first 401 so we can mark reconnect immediately.
@ComputelessComputer
ComputelessComputer merged commit ed3be96 into main Aug 29, 2026
21 checks passed
@ComputelessComputer
ComputelessComputer deleted the fix/outlook-nango-500-body branch August 29, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant