Title: bug: a raw 64-character idempotencyKey skips run scope · Issue #5130 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: bug: a raw 64-character idempotencyKey skips run scope · Issue #5130 · triggerdotdev/trigger.dev
X Title: bug: a raw 64-character idempotencyKey skips run scope · Issue #5130 · triggerdotdev/trigger.dev
Description: Provide environment information System: macOS 27.2, arm64 Node: 26.13.0 npm: 11.20.0 @trigger.dev/core: 4.8.5 (same code on main at 2fbd5c7) Describe the bug The docs say a raw string passed as idempotencyKey defaults to run scope. A str...
Open Graph Description: Provide environment information System: macOS 27.2, arm64 Node: 26.13.0 npm: 11.20.0 @trigger.dev/core: 4.8.5 (same code on main at 2fbd5c7) Describe the bug The docs say a raw string passed as ide...
X Description: Provide environment information System: macOS 27.2, arm64 Node: 26.13.0 npm: 11.20.0 @trigger.dev/core: 4.8.5 (same code on main at 2fbd5c7) Describe the bug The docs say a raw string passed as ide...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/5130
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: a raw 64-character idempotencyKey skips run scope","articleBody":"### Provide environment information\n\n```\nSystem: macOS 27.2, arm64\nNode: 26.13.0\nnpm: 11.20.0\n@trigger.dev/core: 4.8.5 (same code on main at 2fbd5c7)\n```\n\n### Describe the bug\n\nThe docs say a raw string passed as `idempotencyKey` defaults to `run` scope. A string of exactly 64 characters doesn't get it.\n\n`makeIdempotencyKey` calls `isIdempotencyKey`, which returns true for any 64-character string ([idempotencyKeys.ts#L53-L62](https://github.com/triggerdotdev/trigger.dev/blob/2fbd5c7cf4e9c8e19b88e2b72a7133795611e33d/packages/core/src/v3/idempotencyKeys.ts#L53-L62), [#L91-L105](https://github.com/triggerdotdev/trigger.dev/blob/2fbd5c7cf4e9c8e19b88e2b72a7133795611e33d/packages/core/src/v3/idempotencyKeys.ts#L91-L105)). So the key goes to the API unchanged, without the parent run ID. The catalog doesn't know the string either, so `trigger_internal` sends no `idempotencyKeyOptions` ([shared.ts#L2442-L2445](https://github.com/triggerdotdev/trigger.dev/blob/2fbd5c7cf4e9c8e19b88e2b72a7133795611e33d/packages/trigger-sdk/src/v3/shared.ts#L2442-L2445)). The key ends up global.\n\nA SHA-256 hex digest is 64 characters, and hashing your own dedup identity is a common way to build a key (#4626 says the same). So `idempotencyKey: sha256(orderId)` inside a task dedupes across parent runs. If a replay of the parent, or the next run of a scheduled parent, triggers the child with the same digest within the 30-day default TTL, it gets the existing child run back instead of a new one. With a key of any other length it would get a new run.\n\nExpected: a raw string gets run scope whatever its length, as the docs say. #4626 removed this assumption from `reset()`. The trigger path still has it.\n\n### Reproduction repo\n\nNo repo needed, the script is below. Source: https://github.com/triggerdotdev/trigger.dev/blob/2fbd5c7cf4e9c8e19b88e2b72a7133795611e33d/packages/core/src/v3/idempotencyKeys.ts#L53-L62\n\n### To reproduce\n\nThe script uses the published `@trigger.dev/core` and makes no API calls. It sets a task context for two different parent runs and prints the key the SDK would send in each.\n\n```js\nimport { createHash } from \"node:crypto\";\nimport { makeIdempotencyKey, taskContext } from \"@trigger.dev/core/v3\";\n\nconst insideParentRun = (runId) =>\n taskContext.setGlobalTaskContext({\n ctx: { run: { id: runId }, attempt: { number: 1 } },\n worker: {},\n });\n\nconst shortKey = \"order-1234\";\nconst digestKey = createHash(\"sha256\").update(\"order-1234\").digest(\"hex\");\n\nconst keysFor = async (runId) => {\n insideParentRun(runId);\n return {\n short: await makeIdempotencyKey(shortKey),\n digest: await makeIdempotencyKey(digestKey),\n };\n};\n\nconst runA = await keysFor(\"run_parent_a\");\nconst runB = await keysFor(\"run_parent_b\");\n\nconsole.log(`digest key length: ${digestKey.length}`);\nconsole.log(`10-char key, run-scoped (differs per parent run): ${runA.short !== runB.short}`);\nconsole.log(`64-char key, run-scoped (differs per parent run): ${runA.digest !== runB.digest}`);\nconsole.log(`64-char key sent as-is: ${runA.digest === digestKey}`);\n```\n\n```\nnpm i @trigger.dev/core@4.8.5 && node repro.mjs\n```\n\nOutput:\n\n```\ndigest key length: 64\n10-char key, run-scoped (differs per parent run): true\n64-char key, run-scoped (differs per parent run): false\n64-char key sent as-is: true\n```\n\n### Suggested fix\n\nDo what #4626 did for `reset()`: treat a 64-character string as already hashed only when the catalog knows it (`getIdempotencyKeyOptions(key) !== undefined`). Otherwise hash it with run scope, like any other raw string.\n\nOne case gets worse with that change: a key made with `idempotencyKeys.create()` in another process, or in an earlier run, since the catalog is cleared at each run boundary. For example, a key created in a backend and passed to a task in the payload. The catalog doesn't know it, so it would be hashed a second time. If that case matters, the SDK needs a marker it can check at trigger time, such as a prefix on keys from `create()`. Until then, one line in the idempotency docs saying that 64-character raw strings are sent as-is would help.\n\n### Additional information\n\nI found this by reading the source after seeing #4626, and checked it with the script above. I haven't tested it against a deployed project.\n","author":{"url":"https://github.com/heykadirhan","@type":"Person","name":"heykadirhan"},"datePublished":"2026-11-16T06:43:40Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/5130"}
| 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:8db97b6c-8026-4487-9e98-390335ec2fab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C38:3ACD90:501779:775DD3:6AFAEAE9 |
| html-safe-nonce | 520e33659cdda306b1eeb56ba0451961708930ebf11eb7d17f9cd16a5d5e215b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzM4OjNBQ0Q5MDo1MDE3Nzk6Nzc1REQzOjZBRkFFQUU5IiwidmlzaXRvcl9pZCI6IjY5MTcxMDk1NDg1NzAwNDUxNjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7bf890a586c9cbab81835b818189658fd3cc4d12dd029ce79ec616a7d0e6b89f |
| hovercard-subject-tag | issue:6415799364 |
| 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/triggerdotdev/trigger.dev/5130/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ae07f7a726bb70216441c01af6382a634fa1dbcc243f17d82d946194f1343260/triggerdotdev/trigger.dev/issues/5130 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ae07f7a726bb70216441c01af6382a634fa1dbcc243f17d82d946194f1343260/triggerdotdev/trigger.dev/issues/5130 |
| og:image:alt | Provide environment information System: macOS 27.2, arm64 Node: 26.13.0 npm: 11.20.0 @trigger.dev/core: 4.8.5 (same code on main at 2fbd5c7) Describe the bug The docs say a raw string passed as ide... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | heykadirhan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913 |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| 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 | 12fff95459b24b0f882a66698ee6a36a5934d247 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width