Skip to content

[PR-verification] fix(oauth): deterministic provider error detail on refresh-token rejection - #1144

Closed
Baz (bazarnov) wants to merge 3 commits into
mainfrom
verify/oauth-provider-error-detail-first-line
Closed

Baz (bazarnov) wants to merge 3 commits into
mainfrom
verify/oauth-provider-error-detail-first-line

Conversation

@bazarnov

Copy link
Copy Markdown
Contributor

Validation run for a CDK OAuth error-detail change: a deterministic single-line provider detail is appended to the refresh-token rejection message, with the full provider body kept in internal_message. Not for merge.

When an OAuth refresh request is rejected, the CDK replaced the provider's
own diagnostic with one fixed sentence. `_wrap_refresh_token_exception`
already parsed the error body to decide whether the failure was a refresh
token failure and then discarded it.

For Microsoft Entra that body carries an AADSTS code which separates
completely different root causes: AADSTS50173 (grant revoked, e.g. the user
changed their password), AADSTS7000218 / AADSTS700025 (client type or secret
misconfiguration) and AADSTS50076 / AADSTS50078 / AADSTS700082 (Conditional
Access requiring an interactive sign-in). All of them collapsed into the same
string, and no AADSTS code reached production failure summaries.

The parsed body is now reused instead of being parsed a second time, the full
provider response goes to `internal_message` so it lands in the logs, and a
short single-line `error` / `error_description` detail is appended after the
existing actionable guidance in the user-facing message. Bodies that are
empty, non-JSON or not a JSON object degrade to the previous behaviour
without raising. Everything surfaced is run through secret redaction, and the
authenticator's own refresh token and client secret are redacted explicitly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- Append only the first line of `error_description`, capped at 120 characters: Microsoft Entra
  puts the AADSTS code and its sentence there and follows with per-request Trace ID,
  Correlation ID, Timestamp and issue dates, which otherwise made the same failure produce a
  different message on every attempt and defeated grouping by failure summary. The full body
  still lands in `internal_message`.
- Skip non-string `error` / `error_description` values instead of rendering their repr.
- Docstring: AADSTS700082 is refresh-token expiry due to inactivity, not Conditional Access
  (https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes); which
  provider errors reach this path at all is set by `refresh_token_error_*`.
- Tests: assert the trailing lines never reach `message`; the redaction test now uses distinct
  credential values and resets config-level secrets first (the previous values equalled their
  field names and a secret leaked from an earlier test masked them on its own); add the
  declarative-authenticator path used by manifest connectors; align Entra fixtures with the
  official wording.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

Testing This CDK Version

You can test this version of the CDK using the following:

# Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@verify/oauth-provider-error-detail-first-line#egg=airbyte-python-cdk[dev]' --help

# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch verify/oauth-provider-error-detail-first-line

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test - Runs connector tests with the updated CDK
  • /prerelease - Triggers a prerelease publish with default arguments
  • /poe build - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
  • /poe <command> - Runs any poe command in the CDK environment
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

PyTest Results (Fast)

4 373 tests  +10   4 361 ✅ +10   9m 33s ⏱️ -14s
    1 suites ± 0      12 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit de26718. ± Comparison against base commit 64bdfc9.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

PyTest Results (Full)

4 376 tests   4 364 ✅  13m 34s ⏱️
    1 suites     12 💤
    1 files        0 ❌

Results for commit de26718.

@bazarnov
Baz (bazarnov) deleted the verify/oauth-provider-error-detail-first-line branch September 3, 2026 16:32
devin-ai-integration Bot added a commit that referenced this pull request Sep 3, 2026
Apply bazarnov's review on #1138, ported from de26718 (#1144):
- cap provider detail at 120 chars and keep only the first line of
  error_description, so Entra trace ids / timestamps stay out of the
  user-facing message and the same failure yields the same summary
- guard error/error_description on isinstance(str)
- docstring: AADSTS700082 is an expired/revoked grant; reachability
  depends on refresh_token_error_*
- tests: distinct credential values + update_secrets([]) so the redaction
  test exercises the explicit pair redaction; assert trailing marker is
  absent from the user-facing message; add declarative authenticator test

Co-authored-by: bazarnov <bazarnov@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

2 participants