Repository navigation
Fix AgentID link: call global fetch bare, not as a method (Workers Illegal-invocation) - #189
Merged
Merged
Conversation
|
…legal-invocation) The OIDC client stored the bare global `fetch` on the instance (`this.fetchImpl = ... ?? fetch`) and called it as `this.fetchImpl(...)`. On Cloudflare Workers the native fetch throws "Illegal invocation" when its receiver is anything but the global realm, so every real token-exchange and JWKS request failed with: token endpoint unreachable: Illegal invocation: function called with incorrect `this` reference which surfaced to owners as "Verification failed. Could not verify the AgentID sign-in." — no link could ever complete in production. The mocked tests inject their own fetch, so the real global-fetch path was never exercised and CI stayed green. Wrap the fallback in an arrow so the global is always reached by a bare `fetch(...)` call, matching the existing convention in payments/arc.ts, circle-facilitator.ts and cdp-facilitator.ts. Add a regression test that spies on the global fetch and asserts the client never invokes it with the client instance as receiver. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNqTSRyDjL1LcayDuUeDkr
maxfain
force-pushed
the
claude/busy-galileo-l8wc2f
branch
from
October 9, 2026 20:30
9f5e75c to
e47ea60
Compare
|
🔎 Console preview: https://3cb47047.basedagents-console.pages.dev (Passkey ceremonies only work on app.basedagents.ai — previews are for UI review.) |
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.
What
The AgentID OIDC client stored the bare global
fetchon the instance (this.fetchImpl = … ?? fetch) and called it asthis.fetchImpl(...). On Cloudflare Workers the native fetch throws "Illegal invocation" when its receiver is not the global realm, so every token-exchange and JWKS request failed with:which surfaced to owners as "Verification failed. Could not verify the AgentID sign-in." — no link could ever complete in production.
Why CI stayed green
The OIDC tests inject a mock
fetch, so the real global-fetch fallback path was never exercised.Fix
Wrap the fallback in an arrow so the global is always reached by a bare
fetch(...)call, matching the existing convention inpayments/arc.ts,circle-facilitator.ts, andcdp-facilitator.ts:Plus a regression test that spies on the global
fetchand asserts the client never invokes it with the instance as receiver (fails against the old code, passes now).Verification
typecheck,check-positioning,sync-positioning --check,sync-skill --checkall greencircle_testagainstauth.agentid.com→GET /v1/agents/ag_EaGeRhitpSsPPxG3P9A5Q86qMoHTv2hiiT1u8iEq4YV7/agentidnow returnsverified: trueDeploy note
Production already carries this fix via a direct
wrangler deploy; this PR lands it onmainso the next CI deploy frommaindoesn't silently revert it.🤖 Generated with Claude Code
https://claude.ai/code/session_01NNqTSRyDjL1LcayDuUeDkr
Generated by Claude Code