fix(oauth): improve refresh-token error message; remove 'please' and dead placeholder - #1040
Conversation
…dead placeholder
The CDK's DeclarativeOauth2Authenticator surfaced a refresh-token
error as 'Refresh token is invalid or expired. Please re-authenticate
from Sources/<your source>/Settings.' That message violates the
writing-good-error-messages guidelines on multiple counts:
- Remediation embedded in the user-facing string ('Please re-authenticate ...')
- 'Please' emotional/blame language
- Literal '<your source>' placeholder that never gets substituted
- Over-claims 'invalid or expired' when the 4xx may actually be a
malformed refresh request (e.g. Gong's generate-customer-token
endpoint, tracked in airbytehq/airbyte-internal-issues#16467)
The new message states only the observed condition without
over-claiming the cause or instructing the user to take an action
that may not resolve the failure. The internal_message now also
captures the HTTP status code so developers debugging logs can
see the upstream response status.
Resolves airbytehq/airbyte-internal-issues#16468
Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou 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/1780092283-fix-oauth-refresh-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/1780092283-fix-oauth-refresh-error-messagePR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
|
Closing as superseded. The goals here (drop "please" and the dead |
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
Summary
The CDK's
AbstractOauth2Authenticator._make_handled_request(used byDeclarativeOauth2Authenticatorand every other source that talks to an OAuth refresh endpoint) surfaces this user-facing string when the refresh response matches the configured refresh-token error indicators:That string violates the writing-good-error-messages guidelines on multiple counts. This PR replaces it with a narrower, deterministic message and keeps useful detail in
internal_message.Specific problems with the current message:
Please re-authenticate from Sources/<your source>/Settings.violates the rule that remediation belongs in docs / UI rather than embedded as a sentence in the user-facing string. The wording is also brittle (it references a specific UI navigation path).generate-customer-token, tracked inairbytehq/airbyte-internal-issues#16467) return a matching 400 when the refresh request is malformed even though the refresh token itself is still valid. In that case telling the user to re-authenticate is a dead-end.<your source>reaches end users instead of being replaced with the actual connector name.internal_message==message: No additional developer-facing detail is captured; HTTP status code in particular is useful when debugging logs.Change:
message→"OAuth token refresh failed with a refresh-token error response."— declarative, names the failing operation, doesn't over-claim the cause, no remediation embedded.internal_message→ includes the HTTP status code and a pointer to the existing DEBUG-level token-refresh log (emitted via_log_response) for the full response body.failure_typeis unchanged (config_error) since the common true-positive case (genuinely expired/invalid refresh token) still requires the user to re-authenticate.Updated the corresponding parametrized assertion in
unit_tests/.../test_requests_native_auth.py::TestOauth2Authenticator::test_refresh_access_token_wrapped.This is a CDK-level message-only change — no schema / state / spec changes, so a patch version bump is appropriate. The upstream Gong root cause is a separate fix tracked in
airbytehq/airbyte-internal-issues#16467/ draft PRairbytehq/airbyte-python-cdk#919.Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/16468
Review & Testing Checklist for Human
messagetext is acceptable per writing-good-error-messages. Note the deliberate omission of an embedded remediation hint — see the false-positive discussion inairbytehq/airbyte-internal-issues#16468."Refresh token is invalid or expired". A repo-wide search ofairbytehq/airbyteandairbytehq/airbyte-python-cdkcame up empty, but the platform / UI repos were not exhaustively searched.internal_messageis acceptable. The refresh response body is intentionally NOT included ininternal_message(still logged at DEBUG via_log_response) to avoid potentially leaking client_id / scope hints into the structured exception.Notes
airbytehq/airbyte-python-cdk#960also targets OAuth error messages inDeclarativeOauth2Authenticator, but on a different code path (notabstract_oauth.py:308). No overlap.Link to Devin session: https://app.devin.ai/sessions/b2160548fe034336ab68aba9f1eee15b