Skip to content

docs: use the run ID as the idempotency key for external services - #4953

Merged
matt-aitken merged 1 commit into
mainfrom
docs/idempotency-run-id-provider-key
Sep 18, 2026
Merged

matt-aitken merged 1 commit into
mainfrom
docs/idempotency-run-id-provider-key

Conversation

@matt-aitken

Copy link
Copy Markdown
Member

Summary

Follow-up to #4952. The new "Side effects inside run()" section told readers to derive the provider's idempotency key from a payload ID, but the more general answer is the run ID: ctx.run.id is stable across every attempt of a run, is always available, and is the same value the default run scope already mixes into a Trigger.dev idempotency key.

The Stripe refund example now keys the provider call on ctx.run.id, and a short paragraph explains when a business ID from the payload is the better choice (when the same task can be triggered more than once for the same order and you want deduplication across separate runs).

Docs only.

The run ID is stable across every attempt of a run, so it is the natural
key to hand to a payment provider when the task has no business ID to use.
The refund example now keys Stripe on ctx.run.id and notes when a payload
ID is the better choice.
@changeset-bot

changeset-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8d3fd9b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Walkthrough

The refund documentation now uses ctx.run.id for provider idempotency keys. The task accepts ctx, and the email trigger uses a run-scoped idempotency key. The documentation states that run IDs deduplicate retries within one run only. It recommends a Trigger.dev idempotency key or a business identifier for deduplication across separate runs.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 8d3fd

The example can lead users to rely on provider-side keys for long-lived refund deduplication, risking duplicate refunds after the retention window. Document the limit and durable-state alternative before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the documentation change and its rationale, but it omits the template sections for the issue reference, checklist, testing, changelog, and screenshots. Add the required template sections. Include the issue reference, complete the checklist, describe testing or state that no code testing was required, add a short changelog entry, and provide screenshots or state that they are not applicable…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main documentation change: using the run ID as the idempotency key for external services.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Resolution

Add the required template sections. Include the issue reference, complete the checklist, describe testing or state that no code testing was required, add a short changelog entry, and provide screenshots or state that they are not applicable.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2c39028b-6b01-4be1-871a-76896fecdd50

📥 Commits

Reviewing files that changed from the base of the PR and between adc4979 and 8d3fd9b.

📒 Files selected for processing (1)
  • docs/idempotency.mdx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (1)
MDX documentation pages must include frontmatter with title (required), description (required), and sidebarTitle (optional) in YAML format Use Mintlify components for structured content: , , , , ,

📄 CodeRabbit inference engine (docs/CLAUDE.md)

Files:

  • docs/idempotency.mdx

Comment thread docs/idempotency.mdx
@matt-aitken
matt-aitken added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit c84bf7f Sep 18, 2026
31 checks passed
@matt-aitken
matt-aitken deleted the docs/idempotency-run-id-provider-key branch September 18, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants