You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 81ebf24
Browse filesBrowse the repository at this point in the historyBrowse files
fix(batch): clear idempotency keys pointing at dead runs in batchTrigger
The single-trigger path clears an idempotency key when the run it points at
reached a clearable terminal state — `IdempotencyKeyConcern.handleExistingRun`
guards on `shouldIdempotencyKeyBeCleared(existingRun.status)`. The batch path
only tested time expiry, so `batchTrigger` with a key pointing at a dead run
returned that FAILED run as `isCached: true`, and kept returning it on every
retry.
The batch path could not make that check: `findRunsByIdempotencyKeys` selected
five columns and `status` was not one of them, so `cachedRun` had no status to
test. The fix spans three files:
- `run-store/types.ts`: `IdempotencyKeyRunMatch` gains `status`.
- `run-store/PostgresRunStore.ts`: the lookup selects `"status"`.
`delegatingRunStore` and `runOpsStore` forward unchanged.
- `batchTriggerV3.server.ts`: the cached-run guard becomes
`keyTimeExpired || shouldIdempotencyKeyBeCleared(cachedRun.status)`, in the
same branch as time expiry so the run lands in `expiredRunIds` and the stale
key is cleared — otherwise it would survive to the next batch.
Policy stays owned by the webapp (`shouldIdempotencyKeyBeCleared` lives in
`v3/taskStatus.ts`); the store just returns one more column.
Fixes#4819.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fix `batchTrigger` returning a stale failed run when its idempotency key points at a run that crashed, timed out, or otherwise failed. The key is now cleared and a fresh run triggered, matching single-`trigger` behaviour
return`SELECT "id", "createdAt", "friendlyId", "idempotencyKey", "idempotencyKeyExpiresAt" FROM "TaskRun" WHERE "runtimeEnvironmentId" = $${base+1} AND "taskIdentifier" = $${base+2} AND "idempotencyKey" = $${base+3}`;
1864
+
return`SELECT "id", "createdAt", "friendlyId", "idempotencyKey", "idempotencyKeyExpiresAt", "status" FROM "TaskRun" WHERE "runtimeEnvironmentId" = $${base+1} AND "taskIdentifier" = $${base+2} AND "idempotencyKey" = $${base+3}`;
0 commit comments