fix(events-processor): Ensure grouped by are set when matching a single flat filter#710
Merged
vincent-pochet merged 1 commit intomainfrom Mar 3, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR ensures pricing_group_keys / grouped_by are preserved when an event matches a single “default” flat filter (i.e., when ChargeFilterID / Filters are not set), so grouped-by enrichment still happens.
Changes:
- Propagate
PricingGroupKeyswhen building a charge’s default flat filter (ToDefaultFilter). - Extend enrichment tests to cover single-flat-filter default-bucket behavior with
PricingGroupKeys. - Update flat filter model tests to assert
PricingGroupKeysare retained throughToDefaultFilter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| events-processor/processors/events_processor/enrichment_service_test.go | Adds a regression test ensuring GroupedBy is populated from PricingGroupKeys even when the match falls back to the default bucket. |
| events-processor/models/flat_filters_test.go | Updates ToDefaultFilter test expectations to include PricingGroupKeys. |
| events-processor/models/flat_filters.go | Updates ToDefaultFilter() to copy PricingGroupKeys into the default filter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
events-processor/processors/events_processor/enrichment_service_test.go
Outdated
Show resolved
Hide resolved
93c4bdd to
f9b5fbd
Compare
D1353L
approved these changes
Mar 3, 2026
f9b5fbd to
2a1b5db
Compare
This was referenced Mar 5, 2026
vincent-pochet
added a commit
to getlago/lago-api
that referenced
this pull request
Mar 6, 2026
## Context This PR is related to getlago/lago#712 Two issues where recently identified in the events-processor: - Events with `timestamp` formatted as ISO 8601 string were not processed correctly and were pushed to the dead letter queue (fixed with getlago/lago#709) - Pricing group keys were not assigned correctly to the events when no filters were present on a given charge, leading to inconsistent data in the `events_enriched_expanded` kafka topic and clickhouse table (fixed with getlago/lago#710) Because of this two issues, some events will need to be reprocessed, either completely (for the timestamp issue as not `events_enriched` record were created), or partially (for the grouped_by issue as we only need to re-create the `events_enriched_expanded` record) ## Description This PR adds two rake tasks that will allow full or partial (to only produce events_enriched_expanded records) processing of events_raw. - `events:reprocess` will fetch clickhouse `events_raw` records and push them for reprocessing in the kafka topic. It takes multiple arguments: - `ORGANIZATION_ID` - An optional `SUBSCRIPTION_IDS to filter on a set of subscription - An optional `BM_CODES` to filter on a set of billable metrics - `REPROCESS` default to `true`, to only refresh the `events_enriched_expanded` - `events:deduplicate_enriched_expanded` will remove duplicated events to ensure a coherent state of the `events_enriched_expanded` table, mitigating the eventual consistency of Clickhouse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the assignment of pricing_group_keys/grouped_by on event_enriched_expanded when no charge_filter_id is nil