Skip to content

Comments

fix(trogon_commanded): validate command and aggregate identity configuration in CommandHandlerCase#235

Draft
yordis wants to merge 1 commit intomasterfrom
fix/command-handler-case-identity
Draft

fix(trogon_commanded): validate command and aggregate identity configuration in CommandHandlerCase#235
yordis wants to merge 1 commit intomasterfrom
fix/command-handler-case-identity

Conversation

@yordis
Copy link
Member

@yordis yordis commented Sep 14, 2025

Summary

  • CommandHandlerCase now validates that command and aggregate identity configuration match (field name and prefix) before running assertions
  • Catches misconfigurations that previously went undetected: wrong prefix, wrong identifier field, and nil UUID extraction
  • Validation only runs when both command and aggregate have identity config — plain struct aggregates (e.g., used with register_transaction_script) skip validation, matching production behavior
  • No data transformation — events and state are compared as-is, matching real Commanded runtime behavior where the prefix only affects stream routing

Test plan

  • Existing 26 CommandHandlerCase tests pass unchanged (backward compatible)
  • New tests: matching config passes, mismatched prefix fails, mismatched field fails, nil UUID extraction fails, assert_error path validates identity
  • Trogon command + plain struct aggregate skips validation
  • Neither side having identity config works unchanged

@coderabbitai
Copy link

coderabbitai bot commented Sep 14, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/command-handler-case-identity

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 and usage tips.

@yordis yordis force-pushed the fix/command-handler-case-identity branch 2 times, most recently from 3362d9c to 1c9a719 Compare September 14, 2025 23:36
@yordis yordis force-pushed the master branch 4 times, most recently from b52f4ce to aa8e503 Compare February 11, 2026 22:43
@yordis yordis force-pushed the fix/command-handler-case-identity branch from 44e2045 to 6473f23 Compare February 15, 2026 21:40
@cursor
Copy link

cursor bot commented Feb 15, 2026

PR Summary

Low Risk
Test-support-only changes that add additional assertions and validation; risk is limited to potentially causing previously passing tests to fail when identity configuration is inconsistent.

Overview
CommandHandlerCase now validates command vs aggregate identity configuration (identifier field + identity_prefix) before running assert_events/assert_state/assert_error, and fails fast if the aggregate UUID cannot be extracted via Commanded middleware.

The assertion helpers were refactored to share a run_and_assert/5 wrapper (including clearer failure messages for unexpected success/error paths), and a new ExUnit suite covers matching config, mismatched field/prefix, nil UUID extraction, and backward-compatible behavior when identity config is absent on one or both sides.

Written by Cursor Bugbot for commit decfb1c. This will update automatically on new commits. Configure here.

@yordis yordis changed the title fix/command handler case identity fix(trogon_commanded): apply identity prefix transformation in CommandHandlerCase Feb 16, 2026
@yordis yordis changed the title fix(trogon_commanded): apply identity prefix transformation in CommandHandlerCase fix(trogon_commanded): validate command and aggregate identity configuration in CommandHandlerCase Feb 16, 2026
@yordis yordis force-pushed the fix/command-handler-case-identity branch from d33ebf7 to 7c51b61 Compare February 16, 2026 20:41
@yordis yordis force-pushed the fix/command-handler-case-identity branch from 7c51b61 to decfb1c Compare February 17, 2026 01:06
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

validate_aggregate_uuid_extraction(command, command_module)
else
:ok
end
Copy link

Choose a reason for hiding this comment

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

One-sided identity config silently bypasses validation

Medium Severity

validate_identity_configuration/2 only validates when both command and aggregate expose identity functions. If only one side is configured, it returns :ok and proceeds. This leaves misconfigured tests passing silently, so CommandHandlerCase can still hide identity mismatches instead of surfacing them.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant