[Bug] Anthropic API Error: Invalid JWT in Edge Function authentication
Bug Description
claude didnt succeed in fixing LLM API call. Codex did it better.
The failure was an auth-token failure, not a translation-model failure.
When you clicked “translate with AI”, the frontend called translateProduct() in aiProductTranslationService.ts (line 129), which calls callOpenAI().
callOpenAI() invoked Supabase Edge Function ai-proxy from openaiConfig.ts (line 102).
Your console shows:
[openaiConfig] ai-proxy error detail: {code: 401, message: 'Invalid JWT'}
then FunctionsHttpError: Edge Function returned a non-2xx status code
That exact payload (code: 401, message: Invalid JWT) is from the Edge gateway auth layer, meaning the request arrived with an invalid/missing user JWT.
ai-proxy requires a valid Authorization bearer token and validates user auth at ai-proxy/index.ts (line 40) and ai-proxy/index.ts (line 54).
If JWT is invalid, request is rejected before translation logic can run.
So the break happened before OpenAI translation execution.
It was not caused by prompt content, product text, or translation JSON parsing.
Why this happened in practice: session/JWT desynchronization edge case in frontend auth lifecycle (custom session restore/guard logic in authContext.tsx (line 977) and related flows), so functions.invoke could run without a fresh valid user bearer token.
Fix applied: openaiConfig.ts (line 24) now explicitly:
gets current session token,
refreshes session if needed,
sends Authorization: Bearer [REDACTED_TOKEN] access_token> explicitly on invoke (openaiConfig.ts (line 97)).
Current status: fix is committed locally (6a51687d) but not deployed until pushed, so staging still shows old behavior until deployment triggers.
Environment Info
- Platform: darwin
- Terminal: iTerm.app
- Version: 2.1.78
- Feedback ID: 1f1b3329-6c08-4c72-8bd2-62b748a41199
Errors
[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/massimo/.local/share/claude/versions/2.1.78 (expected in multi-process scenarios)\n at gVT (/$bunfs/root/src/entrypoints/cli.js:2648:2174)\n at cIq (/$bunfs/root/src/entrypoints/cli.js:2648:1318)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T07:49:29.479Z"},{"error":"Error: Request was aborted.\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:448:3940)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T07:51:45.191Z"},{"error":"Error: Request was aborted.\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:448:3940)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T08:51:08.654Z"},{"error":"Error: Request was aborted.\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:448:3940)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T09:11:32.318Z"},{"error":"Error: Failed to fetch version from https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/latest: ECONNREFUSED\n at DjK (/$bunfs/root/src/entrypoints/cli.js:2646:2074)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T10:28:47.417Z"},{"error":"Error: Failed to fetch version from https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/latest: ECONNREFUSED\n at DjK (/$bunfs/root/src/entrypoints/cli.js:2646:2074)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T10:28:47.418Z"},{"error":"Error: 1P event logging: 1 events failed to export (code=ECONNABORTED, timeout of 10000ms exceeded)\n at queueFailedEvents (/$bunfs/root/src/entrypoints/cli.js:7097:2694)\n at async doExport (/$bunfs/root/src/entrypoints/cli.js:7097:1563)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T12:27:31.929Z"},{"error":"Error: {\"message\":\"Failed to export 1 events (code=ECONNABORTED, timeout of 10000ms exceeded)\",\"originalLine\":\"7097\",\"originalColumn\":\"1715\",\"line\":\"7097\",\"column\":\"1715\",\"sourceURL\":\"/$bunfs/root/src/entrypoints/cli.js\",\"stack\":\"Error: Failed to export 1 events (code=ECONNABORTED, timeout of 10000ms exceeded)\\n at doExport (/$bunfs/root/src/entrypoints/cli.js:7097:1715)\\n at processTicksAndRejections (native:7:39)\",\"name\":\"Error\"}\n at error (/$bunfs/root/src/entrypoints/cli.js:2594:27423)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:104:81721)\n at jA4 (/$bunfs/root/src/entrypoints/cli.js:104:82265)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:105:17366)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T12:27:31.930Z"},{"error":"Error: Failed to fetch version from https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/latest: timeout of 30000ms exceeded\n at DjK (/$bunfs/root/src/entrypoints/cli.js:2646:2074)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-18T12:27:39.364Z"},{"error":"Error:…
Note: Content was truncated.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗