Title: @clerk/backend: decodeJwt throws a raw SyntaxError for a malformed token · Issue #9263 · clerk/javascript · GitHub
Open Graph Title: @clerk/backend: decodeJwt throws a raw SyntaxError for a malformed token · Issue #9263 · clerk/javascript
X Title: @clerk/backend: decodeJwt throws a raw SyntaxError for a malformed token · Issue #9263 · clerk/javascript
Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk support via email or Discord (if you hav...
Open Graph Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...
X Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...
Opengraph URL: https://github.com/clerk/javascript/issues/9263
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@clerk/backend: decodeJwt throws a raw SyntaxError for a malformed token","articleBody":"### Preliminary Checks\n\n- [x] I have reviewed the documentation: https://clerk.com/docs\n\n- [x] I have searched for existing issues: https://github.com/clerk/javascript/issues\n\n- [x] I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)\n\n- [x] This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.\n\n\n### Reproduction\n\n-\n\n### Publishable key\n\n-\n\n### Description\n\n`decodeJwt` throws a plain `SyntaxError` if a token has three segments but they're not valid base64url. It should throw a `TokenVerificationError` like it does for other bad tokens.\n```\ncurl -i -H 'Authorization: Bearer aaa.bbb.ccc' https://example.com/\n```\n\n**Steps to reproduce:**\n\n```typescript\nconst { decodeJwt } = require('@clerk/backend/jwt')\n\ndecodeJwt('aaa.bbb.ccc')\n```\n\n**Expected behavior**:\n\n`TokenVerificationError`, which is what you get from `decodeJwt('aaaa.bbbb')` or `decodeJwt('notajwt')`.\n\n**Actual behavior**:\n\nThrows `SyntaxError: Unexpected end of data`.\n\ndecodeJwt checks that there are three parts, but the `base64url.parse` and `JSON.parse` calls right after that check aren't wrapped in anything. `decodeJwt('YWJj.YWJj.YWJj')` hits the `JSON.parse` one and throws `SyntaxError: Unexpected token 'a', \"abc\" is not valid JSON.`\n\n### Environment\n\n```Shell\n- @clerk/backend 3.13.2\n```","author":{"url":"https://github.com/ollipa","@type":"Person","name":"ollipa"},"datePublished":"2026-07-28T06:27:45Z","url":"https://github.com/clerk/javascript/issues/9263"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2dbc761e-7e2e-a5f8-f0a0-eec07fa486ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C594:210607:CFED2:12453A:6AFB6769 |
| html-safe-nonce | e8d2d234b57041cb134ad9bb4edc993e51a3ca7d59b766d570a256865adde63a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTk0OjIxMDYwNzpDRkVEMjoxMjQ1M0E6NkFGQjY3NjkiLCJ2aXNpdG9yX2lkIjoiNjQ3NDE3ODQxMDM3NjI5MjIwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a2a34cfdd763a5c61cc30c41b1b6d9bc323a24942f20bb1b5e6b236103bad4b6 |
| hovercard-subject-tag | issue:4995625656 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/clerk/javascript/9263/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b643e5527e59d73a238d76e94be3acfbb82824326c1f31e8345e07f87d9c01f2/clerk/javascript/issues/9263 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b643e5527e59d73a238d76e94be3acfbb82824326c1f31e8345e07f87d9c01f2/clerk/javascript/issues/9263 |
| og:image:alt | Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ollipa |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| go-import | github.com/clerk/javascript git https://github.com/clerk/javascript.git |
| octolytics-dimension-user_id | 49538330 |
| octolytics-dimension-user_login | clerk |
| octolytics-dimension-repository_id | 438331492 |
| octolytics-dimension-repository_nwo | clerk/javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 438331492 |
| octolytics-dimension-repository_network_root_nwo | clerk/javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width