Skip to content

Preserve Cloudflare OAuth token exchange errors - #325

Open
atsaplin wants to merge 1 commit into
cloudflare:mainfrom
atsaplin:fix/cloudflare-oauth-errors-upstream
Open

Preserve Cloudflare OAuth token exchange errors#325
atsaplin wants to merge 1 commit into
cloudflare:mainfrom
atsaplin:fix/cloudflare-oauth-errors-upstream

Conversation

@atsaplin

Copy link
Copy Markdown

Closes #323

What does this change?

Cloudflare OAuth token redemption currently collapses every non-2xx response to null. That makes invalid client credentials indistinguishable from a successful response that omitted an access token. This patch throws an error containing only the HTTP status and standard OAuth error and error_description fields, and adds a focused rejection-path test.

Why is this obviously correct and trivially verifiable?

The change affects one non-2xx branch in the token exchange helper. The test supplies a 401 invalid_client response and asserts the exact sanitized error. Credentials and token values are never read into the message. Successful response handling is unchanged.

Verification

  • pnpm --filter @gadgets/cloudflare-gatekeeper test:run

Checklist

  • This is a small, concrete change; it is not a feature, refactor, or low-value cleanup.
  • I understand that maintainers decide whether the change is obviously correct and trivially verifiable.
  • I have read and followed the contribution guidelines.
@atsaplin

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@github-actions github-actions Bot added the gatekeeper Changes to a gatekeeper integration label Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions Bot added a commit that referenced this pull request Aug 25, 2026
if (!resp.ok) {
resp.body?.cancel();
return null;
const providerError: unknown = await resp.json().catch(() => null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

redeem() is also used by refreshTokens(). Previously a rejected refresh returned null, allowing getAccessToken() to call credentialsExpired(). with this change it now throws so an expired/revoked refresh token will keep failing without prompting reconnection.
If you are able to fix this happy to merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gatekeeper Changes to a gatekeeper integration

2 participants