fix(automations): deduplicationId separator for us-east-1 QStash#3591
fix(automations): deduplicationId separator for us-east-1 QStash#3591saddlepaddle merged 1 commit intomainfrom
Conversation
QStash rejects ":" in deduplicationId ("DeduplicationId cannot contain
':'"). Swap the separator to "_" and drop the ISO8601 string for the
epoch ms so the whole key is [a-zA-Z0-9_-], which QStash accepts.
Same idempotency semantics — minute-bucket uniqueness per automation.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe deduplication identifier format for QStash automation dispatch enqueueing has been modified. The key construction changed from ISO timestamp serialization with a colon delimiter to millisecond epoch time with an underscore delimiter. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a 400 error from QStash us-east-1 that rejects Key observations:
Confidence Score: 5/5Safe to merge — minimal, targeted fix with no edge cases or regressions. The change is a single-line fix to the deduplicationId format. The new format uuid_epochMs is strictly within the [a-zA-Z0-9_-] character set that QStash us-east-1 accepts. Idempotency semantics are unchanged since bucketToMinute still produces the same minute-bucketed timestamp. The dispatch body ISO 8601 scheduledFor field is unaffected. No logic, security, or compatibility concerns. No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/api/src/app/api/automations/evaluate/route.ts | Replaces colon separator and ISO 8601 timestamp with underscore separator and epoch ms in the QStash deduplicationId, resolving a 400 error from the us-east-1 region. Logic is correct and idempotency is preserved. |
Sequence Diagram
sequenceDiagram
participant Scheduler as QStash Scheduler
participant Evaluate as evaluate route
participant DB as Database
participant QStash as QStash batchJSON
Scheduler->>Evaluate: POST signed request
Evaluate->>Evaluate: verify signature
Evaluate->>DB: SELECT due automations
DB-->>Evaluate: automation rows
loop per automation
Evaluate->>Evaluate: bucketToMinute → scheduledFor
Evaluate->>Evaluate: deduplicationId = id_epochMs
end
Evaluate->>QStash: batchJSON with safe deduplicationId
QStash-->>Evaluate: 200 OK
Evaluate->>DB: advance nextRunAt or disable
Evaluate-->>Scheduler: enqueued count
Reviews (1): Last reviewed commit: "fix(automations): use _ and epoch ms in ..." | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
Our prod QStash project (us-east-1) rejects `:` in `deduplicationId`:
`{"error":"DeduplicationId cannot contain ':'"}` — 400 from batchJSON.
Swap the separator to `` and switch from ISO8601 to epoch ms so the whole key is `[a-zA-Z0-9-]`. Idempotency semantics (minute-bucket uniqueness per automation) are unchanged.
Test plan
Summary by cubic
Fixes QStash 400s in us-east-1 by changing the deduplicationId from
${automation.id}:${scheduledFor.toISOString()}to${automation.id}_${scheduledFor.getTime()}. Uses_and epoch ms so the key is alphanumeric/_/-only; idempotency is unchanged.Written for commit 937f56a. Summary will update on new commits.
Summary by CodeRabbit