Skip to content

fix(nats): derive CloudEvents subject from metadata instead of hardcoded TODO#6269

Open
TRIVENI206 wants to merge 1 commit intomindersec:mainfrom
TRIVENI206:fix-nats-subject
Open

fix(nats): derive CloudEvents subject from metadata instead of hardcoded TODO#6269
TRIVENI206 wants to merge 1 commit intomindersec:mainfrom
TRIVENI206:fix-nats-subject

Conversation

@TRIVENI206
Copy link
Copy Markdown

…ded TODO

Summary

This PR replaces the hardcoded CloudEvents subject ("TODO") in the NATS eventing driver with a dynamically derived value from message metadata.

The subject is now determined using the following priority:

  • entity_id
  • repository_id or artifact_id
  • project_id

If none of these values are present, a fallback value ("minder") is used.

This improves event filtering in NATS JetStream and aligns with the CloudEvents specification, while keeping the change minimal and avoiding unrelated refactoring for easier review.

Fixes #6250

Testing

  • Built the NATS module using:
    go build ./internal/events/nats/...

  • Ran tests for the NATS module:
    go test ./internal/events/nats/...

  • Verified that:

    • The code compiles successfully
    • No tests in the NATS module are broken
    • The subject is now set dynamically instead of being hardcoded

…ded TODO

Signed-off-by: TRIVENI206 <trivenireddy206@gmail.com>
@TRIVENI206 TRIVENI206 requested a review from a team as a code owner April 3, 2026 19:21
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 3, 2026

CLA assistant check
All committers have signed the CLA.

@evankanderson
Copy link
Copy Markdown
Member

This seems to be conflicting with the work discussed in #6251 (and runs into the same question as to whether we can get by with simply entity_id given our simplification and standardization on entities last year.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 58.318% (+0.003%) from 58.315%
when pulling ed656cf on TRIVENI206:fix-nats-subject
into 0cbed8a on mindersec:main.

@TRIVENI206
Copy link
Copy Markdown
Author

Thanks for the feedback!

I based the implementation on multiple metadata fields for broader compatibility, but I see the point about standardizing on entity_id.

Would you prefer simplifying this to use only entity_id (with a fallback if missing), or keeping the current priority-based approach?

Happy to update the PR accordingly.

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.

Hardcoded "TODO" subject in CloudEvents NATS driver

4 participants