Skip to content

fix(reporting): reject duplicate event names and same-name event copies in aggregations - #121

Merged
tombonfert merged 6 commits into
mainfrom
fix/event_identity_validation
Oct 14, 2026
Merged

tombonfert merged 6 commits into
mainfrom
fix/event_identity_validation

Conversation

@tombonfert

@tombonfert tombonfert commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Event names identify events in the gold tables (event_id = crc32(name)), but Report never enforced them, so reports could produce colliding or mismatched fact rows without any error. Closes #113.

  • add_event now rejects an event whose name is already registered, including the same object added twice. The existing "Only one ContainerEvent" check and its message are unchanged.
  • _validate_aggregation_events now requires an aggregation's event to be the registered object itself. A different object with a registered name used to pass. It now raises and points to report.get_events_dict()[name].

Behavior change

Re-creating an event with the same name for an aggregation now raises, even if the copy is identical. This differs from the hash-equivalence exception proposed in the issue, because definition hashes leave out result-relevant fields (e.g. required_channels) and a copy never gets the settings add_event applies (set_report_id, set_channel_time).

Other changes

  • Docs and skills (event.md, impulse-events, impulse-reporting): state the uniqueness and identity rule.
  • event.md: event_id is the CRC32 of the event name only, not name + expression.

Test Plan

  • Unit tests added/updated
  • Manual testing completed
  • Documentation updated (if applicable)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No new linter warnings introduced

…registration

- `Report.add_event()` now rejects duplicate event names (including the same object added twice).
- `_validate_aggregation_events()` now requires aggregations to reference the exact registered event object, not just an event with the same name.
- Updated event and reporting docs/skills to clarify uniqueness and object-identity requirements.
- Adjusted `event_id` documentation to reflect that it hashes only the event name.
- Added unit tests covering duplicate-name rejection, same-object re-addition, and aggregation validation for copied/same-name events.
@tombonfert
tombonfert requested a review from a team as a code owner October 14, 2026 07:43
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.21%. Comparing base (1b21ee3) to head (ef2f004).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   90.17%   90.21%   +0.04%     
==========================================
  Files          66       66              
  Lines        6003     6009       +6     
  Branches      755      757       +2     
==========================================
+ Hits         5413     5421       +8     
+ Misses        467      466       -1     
+ Partials      123      122       -1     
Flag Coverage Δ
query_engine 86.66% <ø> (ø)
reporting 94.87% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/impulse_reporting/core/report.py 94.04% <100.00%> (+0.62%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…regation events

Align unit tests with the refined validation error message that names both the aggregation and the missing event.
Event names are used as column names in solved data, which Spark resolves
case-insensitively, so `Report.add_event()` now rejects duplicate event
names ignoring case (using `lower()` to mirror Spark behavior). Added unit
tests covering case-insensitive rejection and casefold-distinct names.
Updated event and reporting docs/skills to clarify the case-insensitive
uniqueness requirement.
…ggregation identity requirements

Update API and report reference docs to state that `Report.add_event()` rejects duplicate event names ignoring case (because Spark resolves solved-data columns case-insensitively) and that aggregations must reference the exact registered event object, not a recreated event with the same name.
Update `_validate_aggregation_events()` to match aggregation events against registered events ignoring case, consistent with `add_event()` case-insensitive uniqueness. Error messages now reference the actual registered event name and suggest `report.get_events_dict()` with the correct key. Added a unit test for an aggregation event whose name differs only by case from a registered event.
…iqueness

Clarify the comment explaining case-insensitive event name comparison in `Report.add_event()` and update the unregistered aggregation error message to be more precise. Rename the corresponding unit test to better express that names distinct in Spark are allowed.
@tombonfert
tombonfert merged commit aec178e into main Oct 14, 2026
6 checks passed
@tombonfert
tombonfert deleted the fix/event_identity_validation branch October 14, 2026 09:57
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.

Validate event identity: reject duplicate event names and aggregations scoped to unregistered same-name events

1 participant