Skip to content

fix: improve OAuth refresh token rejection error message - #1130

Merged
Patrick Nilan (pnilan) merged 2 commits into
mainfrom
devin/1787614944-oauth-refresh-token-error-message
Aug 25, 2026
Merged

Patrick Nilan (pnilan) merged 2 commits into
mainfrom
devin/1787614944-oauth-refresh-token-error-message

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/17024
Related to https://github.com/airbytehq/airbyte-internal-issues/issues/17023

The refresh-token-rejection branch of AbstractOauth2Authenticator._make_handled_request raised an AirbyteTracedException whose user-facing message contained a literal, never-substituted template placeholder and a Cloud-UI-specific path:

Refresh token is invalid or expired. Please re-authenticate from Sources/<your source>/Settings.

Changes in abstract_oauth.py:

  • New user-facing message (no placeholder, UI-agnostic remediation, still config_error):
    Refresh token was rejected by the OAuth provider (invalid, expired, or already used). Re-authenticate this source's credentials in its connection settings.
  • internal_message now carries the provider's actual response instead of duplicating the user message: Refresh token rejected by the OAuth token endpoint. HTTP {status}: {body} (e.g. Linear's 400 {"error":"invalid_request","error_description":"Invalid refresh token"}), and the exception is chained with from e.

Unit test assertions in test_requests_native_auth.py::test_refresh_access_token_wrapped updated to match the new message and to verify the provider response is included in internal_message.

No behavior change: FailureType.config_error is unchanged, so retry semantics are unaffected.

Test plan

  • poetry run pytest unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py — 40 passed
  • poetry run ruff check, poetry run ruff format --check, and poetry run mypy --config-file mypy.ini on the touched module — clean

Link to Devin session: https://app.devin.ai/sessions/ce403907eba74f2c84f3374b1a1f5292

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

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@devin/1787614944-oauth-refresh-token-error-message#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 devin/1787614944-oauth-refresh-token-error-message

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the error reporting when an OAuth refresh token is rejected during AbstractOauth2Authenticator._make_handled_request, replacing a UI-specific/templated user message and enriching the internal diagnostics with provider response details.

Changes:

  • Updates the user-facing AirbyteTracedException.message for refresh-token rejection to be UI-agnostic and clearer.
  • Updates AirbyteTracedException.internal_message to include OAuth provider HTTP status/body details and chains the original exception (from e).
  • Adjusts unit tests to assert the new user message and that provider response information is present in internal_message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py Updates refresh-token rejection exception messaging and adds provider-response details to internal diagnostics.
unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py Updates assertions to match the new user message and verify internal diagnostic content.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-Authored-By: bot_apk <apk@cognition.ai>
@github-actions

Copy link
Copy Markdown

PyTest Results (Fast)

4 363 tests  ±0   4 352 ✅ ±0   6m 54s ⏱️ - 3m 43s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit e91bda4. ± Comparison against base commit 9cc7b80.

@github-actions

Copy link
Copy Markdown

PyTest Results (Full)

4 366 tests  ±0   4 354 ✅ ±0   13m 55s ⏱️ + 1m 49s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit e91bda4. ± Comparison against base commit 9cc7b80.

@aaronsteers
Aaron ("AJ") Steers (aaronsteers) marked this pull request as ready for review August 25, 2026 07:20
@pnilan
Patrick Nilan (pnilan) merged commit 4855c2d into main Aug 25, 2026
28 of 29 checks passed
@pnilan
Patrick Nilan (pnilan) deleted the devin/1787614944-oauth-refresh-token-error-message branch August 25, 2026 14:26
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