Repository navigation
Hotfix: send a User-Agent on Zenodo token requests - #271
Merged
Merged
Conversation
zenodo.org's firewall rejects the bare "node" User-Agent that Node's
built-in fetch sends, returning an HTML 403 ("unusual traffic from your
network") before the request reaches the API. sandbox.zenodo.org does not,
so connecting Zenodo worked on the test site and fails in production.
The code exchange in connect-provider and the refresh in zenodo-oauth both
use the built-in fetch; set an explicit User-Agent on each. The upload path
in zenodo.ts uses node-fetch, whose default User-Agent is not blocked.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connecting Zenodo fails on pipe.jspsych.org for every user. The researcher lands back on
/oauth2/connectwith "Could not connect your storage provider."Cause
zenodo.org's firewall rejects the bare
nodeUser-Agent that Node's built-infetchsends. It returns an HTML 403 ("Access to this resource has been restricted due to unusual traffic from your network") before the request reaches the OAuth endpoint. The proddashboardapilogs show every/api/connectprovidercall failing this way. sandbox.zenodo.org doesn't block that User-Agent, so the test site never showed the problem.Reproduced locally:
curl -A node https://zenodo.org/api/deposit/depositionsgets the firewall page, while-A undici,-A node-fetch, or any DataPipe string gets Zenodo's normal JSON response.Fix
The two Zenodo calls that use the built-in
fetchnow sendUser-Agent: DataPipe (+https://pipe.jspsych.org), defined in the newfunctions/src/user-agent.ts:connect-provider.ts(broken now)zenodo-oauth.ts(would break once 60-day tokens start expiring)The upload path in
zenodo.tsusesnode-fetch, whose default User-Agent isn't blocked, so it's unchanged.Testing
providers-zenodo,providers-zenodo-oauth,oauth-connect-emulator, andzenodo-emulatorpass underemulators:exec(103 tests).Goes straight to
mainas a hotfix; mergemainback intotestafterward.🤖 Generated with Claude Code