Skip to content

feat(wif): retry the exchange and API 401s, and say what to fix on every OAuth error - #273

Open
nicknisi wants to merge 5 commits into
riker/239-spike-the-workos-cli-workos-cli-workos-afrom
wif/p13-cli-268
Open

nicknisi wants to merge 5 commits into
riker/239-spike-the-workos-cli-workos-cli-workos-afrom
wif/p13-cli-268

Conversation

@nicknisi

@nicknisi nicknisi commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Stacked on #268. Review this after it; the diff here is only what was added on top.

What changes

  • Retries. A failed exchange is retried on a network error (including a connection that drops while the response is read) or a 5xx, three attempts in total (0.5 s, then 1 s). A 4xx is final. A request sent with a WIF token is re-sent once after a 401, with a freshly exchanged token.
  • Errors that say what to fix. Every OAuth error from the exchange now has a hint, including unauthorized_client: check that the client has an enabled trust, that workload identity federation is on for the team, and that the client targets a non-production environment.
  • Docs. The READMEs cover retries, unauthorized_client, and WORKOS_ENVIRONMENT_ID being optional (it must match the client's bound environment when set).
  • A WIF failure during a request is reported as itself, not as "Failed to connect to WorkOS API".

The branch also merges main (release 0.24.0), so the release files show in the diff.

Checked

Not checked

github-actions Bot and others added 4 commits October 26, 2026 07:40
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ery OAuth error

Retry the token exchange on a network error or 5xx, up to three attempts,
requesting a fresh GitHub OIDC token each time because WorkOS accepts each
one once. Never retry a 4xx. Re-exchange and re-send an API call once when
the API answers 401.

Handle unauthorized_client, and make each OAuth error hint name the
setting to change.
@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new actionable issue remains.

Summary

Adds bounded WIF token-exchange retries, one retry after an API 401, and clearer OAuth error hints.

  • WIF token exchanges retry temporary failures up to three times.
  • WIF requests refresh their token and resend once after a 401.
  • WIF OAuth errors and setup guides point to the settings to check.
  • The package and release metadata now show version 0.24.0.

Reviews (2) · Last reviewed commit: "fix(wif): retry a dropped response body ..." · Reviewed by Greptile

Comment thread src/lib/wif.ts Resolved
Comment thread src/lib/wif.ts Resolved
…se before re-exchanging

A connection that dropped while the token response body was read ended the exchange as 'the response was not JSON' instead of being retried like any other network failure.

A 401 response was cancelled only after the re-exchange, so a failed re-exchange left it open.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant