Skip to content

docs: mirror the auth-token retry and provider wording from fern-docs - #96

Merged
nd0ut merged 3 commits into
mainfrom
docs/auth-token-retry-sync
Oct 5, 2026
Merged

nd0ut merged 3 commits into
mainfrom
docs/auth-token-retry-sync

Conversation

@nd0ut

@nd0ut nd0ut commented Oct 5, 2026

Copy link
Copy Markdown
Member

Follow-up to #92, which shipped in 0.2.6. Two behaviors landed in the code and never reached the guides:

  • The retry. When Uploadcare refuses a token as expired or out of operations, the editor drops it, fetches another and retries the request once. integrating.md listed those codes as if they always surfaced immediately.
  • The provider. authToken now also takes a { getToken, invalidate } object, which is the shape the File Uploader plugin passes through. plugin.md still called it "the uploader's own cached resolver".

Found by a cross-page consistency pass over the matching fern-docs pages; the same corrections are in fern-docs#425, which AGENTS.md asks to keep in sync with these guides.

Docs only, no code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01REj6M5RMiJpFdPqGgdkBvV

0.2.6 drops a token Uploadcare refuses and retries the request once, and
accepts a `{ getToken, invalidate }` provider, which the plugin now passes
through. Neither was in the guides.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01REj6M5RMiJpFdPqGgdkBvV
Copilot AI balanced review requested due to automatic review settings October 5, 2026 19:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new guidance promises automatic invalidation and retries that generation, edit and job-status requests do not perform.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

This docs-only PR updates authentication guidance to mirror the changes described in fern-docs.

Changes:

  • Documents provider objects and shared token caching.
  • Adds guidance about token invalidation and retry behavior.
File Description
packages/​ai-image-editor/​docs/​guide/​plugin.md Clarifies the uploader’s shared token provider and cache.
packages/​ai-image-editor/​docs/​guide/​integrating.md Adds provider, invalidation and retry guidance.

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

Comment on lines +149 to +151
whatever `cacheAuthToken` says, and calls your `invalidate()` on a refused
token. That is the shape the File Uploader plugin passes through, which is why
the editor inside the uploader shares the uploader's cache. See `authToken`,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Both findings are correct, and I verified them against the code rather than taking them on trust.

startJob() and getJobStatus() are the only two requests the editor makes, and both go out through the raw doFetch in UploadcareApiClient. resolveAuthToken() resolves the token and nothing more, so retryIfFailed is never in that path and nothing calls invalidate() on a refusal. The retry is real, but only for uploads, where upload-client's request helper runs. This PR extended it to the editor, which was wrong.

Fixed in 1a66e35: the guide now says the editor raises the error and stops, and names invalidateAuthToken() as what replaces a spent token. I also corrected the comment on AuthTokenController.provider, which claimed the retry was the reason for the object form; the real reason is that it lets a host drop a token rather than only read one.

The matching claims in fern-docs were wrong the same way and are fixed in uploadcare/fern-docs#425 (00da145).

🤖 Written by Claude Code on behalf of @nd0ut

Comment on lines +162 to +165
refuses the token, or `auth_token_failed` when your function throws. An expired
or spent token reaches you only after the editor has already fetched a new one
and retried the request once, which it can do whenever `authToken` is a
function rather than a plain token. See

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, and this was the more serious of the two. I traced it before changing anything: startJob() and getJobStatus() are the only requests the editor makes, both go out through the raw doFetch in UploadcareApiClient, and resolveAuthToken() resolves the token without wrapping the call. retryIfFailed never runs on that path, for a string, a function or a provider alike, exactly as you describe.

The guarantee is gone. integrating.md now states the opposite outright: the editor raises the error and stops, a spent or expired token keeps being sent until something replaces it, and editor.invalidateAuthToken() is what replaces it. The uc:error paragraph says each code arrives on the first refusal.

Two things worth recording beyond the wording:

  • The same false claim had spread to fern-docs, which had it on three pages plus a blanket statement on the signed-uploads hub. Fixed in uploadcare/fern-docs#425 (00da145), with every retry claim now scoped to uploads and two rows added for the editor case.
  • The retry genuinely does work for uploads through File Uploader and Upload Client, where upload-client's request helper runs. It is the editor that was mis-documented, not the feature.

Worth noting the existing e2e tests were never wrong: they only assert that a provider is accepted and that invalidateAuthToken() forwards to it. Nothing asserted a retry, which is consistent with there not being one.

🤖 Written by Claude Code on behalf of @nd0ut

nd0ut and others added 2 commits October 5, 2026 22:48
Copilot was right on #96. `startJob` and `getJobStatus` go out through a plain
fetch in UploadcareApiClient, and `resolveAuthToken` only resolves: nothing
retries, nothing calls `invalidate()`. The guide promised recovery that does
not happen, and the comment on AuthTokenController.provider claimed the retry
was the reason for the object form.

The guide now says the editor raises the error and stops, and names
`invalidateAuthToken()` as what replaces a spent token.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01REj6M5RMiJpFdPqGgdkBvV
`{ getToken, invalidate }` read as something you have to build yourself, when
the cache the docs already recommend satisfies it as is.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01REj6M5RMiJpFdPqGgdkBvV
@nd0ut
nd0ut merged commit 12d70c1 into main Oct 5, 2026
7 checks passed
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