Skip to content

Commit 0699540

Browse files
devin-ai-integration[bot]bot_apk
andcommitted
fix(oauth): improve refresh-token error message; remove 'please' and 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>
1 parent a7b0929 commit 0699540

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,15 @@ def _make_handled_request(self) -> Any:
305305
failure_type=FailureType.transient_error,
306306
)
307307
if self._wrap_refresh_token_exception(e):
308-
message = "Refresh token is invalid or expired. Please re-authenticate from Sources/<your source>/Settings."
308+
status_code = e.response.status_code if e.response is not None else "unknown"
309309
raise AirbyteTracedException(
310-
internal_message=message, message=message, failure_type=FailureType.config_error
310+
message="OAuth token refresh failed with a refresh-token error response.",
311+
internal_message=(
312+
f"OAuth token refresh failed with HTTP {status_code}; "
313+
"response matched configured refresh-token error indicators "
314+
"(see DEBUG-level token refresh log for full response)."
315+
),
316+
failure_type=FailureType.config_error,
311317
)
312318
raise
313319
except Exception as e:

unit_tests/sources/streams/http/requests_native_auth/test_requests_native_auth.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,11 @@ def test_refresh_access_token_wrapped(
575575
oauth.refresh_access_token()
576576

577577
if wrapped:
578-
error_message = "Refresh token is invalid or expired. Please re-authenticate from Sources/<your source>/Settings."
579-
assert exc_info.value.internal_message == error_message
580-
assert exc_info.value.message == error_message
578+
expected_message = "OAuth token refresh failed with a refresh-token error response."
579+
assert exc_info.value.message == expected_message
580+
assert exc_info.value.internal_message.startswith(
581+
f"OAuth token refresh failed with HTTP {response_code}"
582+
)
581583
assert exc_info.value.failure_type == FailureType.config_error
582584

583585

0 commit comments

Comments
 (0)