Skip to content

DurableEmitter: Default idempotency key#2200

Open
tarcisiozf wants to merge 6 commits into
mainfrom
CRE-4733/durable-emitter-idemp-key
Open

DurableEmitter: Default idempotency key#2200
tarcisiozf wants to merge 6 commits into
mainfrom
CRE-4733/durable-emitter-idemp-key

Conversation

@tarcisiozf

@tarcisiozf tarcisiozf commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This pull request enhances the idempotency handling in the DurableEmitter by automatically generating a deterministic idempotency key when one is not supplied.

Idempotency Key Generation and Testing Improvements:

  • pkg/durableemitter/durable_emitter.go: The Emit method now generates a SHA256-based idempotency key from the source domain, entity type, and event body if the caller does not provide one. This ensures event deduplication and deterministic key generation.
  • pkg/durableemitter/durable_emitter_test.go: Added tests to verify that the idempotency key is correctly generated by default and that a caller-supplied key is preserved. These tests confirm the robustness of the new idempotency logic.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-common

View full report

Comment thread go.mod Outdated
Comment thread pkg/durableemitter/durable_emitter.go
Base automatically changed from CRE-4733/chip-idemp-key to main June 26, 2026 15:29
tarcisiozf and others added 3 commits June 26, 2026 12:37
Co-authored-by: Pavel <177363085+pkcll@users.noreply.github.com>
@tarcisiozf tarcisiozf force-pushed the CRE-4733/durable-emitter-idemp-key branch from e58d1d7 to 103ee23 Compare June 26, 2026 15:37
@tarcisiozf tarcisiozf marked this pull request as ready for review June 26, 2026 15:41
@tarcisiozf tarcisiozf requested a review from a team as a code owner June 26, 2026 15:41
Copilot AI review requested due to automatic review settings June 26, 2026 15:41

Copilot AI 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.

Pull request overview

This PR updates DurableEmitter to automatically set a CloudEvent idempotency key when the caller doesn’t supply one, enabling consistent downstream deduplication.

Changes:

  • Default chipingress.IdempotencyKeyAttr when absent (currently computed from source + type + body with length prefixes).
  • Add unit tests verifying defaulting behavior and preserving caller-supplied keys.
  • Bump pkg/chipingress dependency version in go.mod/go.sum.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/durableemitter/durable_emitter.go Adds default idempotency key computation when missing.
pkg/durableemitter/durable_emitter_test.go Adds tests for defaulting and caller-supplied idempotency keys.
go.mod Updates github.com/smartcontractkit/chainlink-common/pkg/chipingress version.
go.sum Updates checksums for the bumped chipingress module version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/durableemitter/durable_emitter.go Outdated
Comment thread pkg/durableemitter/durable_emitter.go Outdated
Comment thread pkg/durableemitter/durable_emitter_test.go Outdated
tarcisiozf and others added 2 commits June 26, 2026 12:45
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

event, err := chipingress.NewEvent(sourceDomain, entityType, body, parseAttrs(attrKVs...))
attrs := parseAttrs(attrKVs...)
if key, _ := attrs[chipingress.IdempotencyKeyAttr].(string); key == "" {

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.

this is very verbose. there's not a more readable way to handle this?

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.

4 participants