Skip to content

fix(events-processor): Ensure grouped by are set when matching a single flat filter#710

Merged
vincent-pochet merged 1 commit intomainfrom
fix-pricing-group-keys
Mar 3, 2026
Merged

fix(events-processor): Ensure grouped by are set when matching a single flat filter#710
vincent-pochet merged 1 commit intomainfrom
fix-pricing-group-keys

Conversation

@vincent-pochet
Copy link
Contributor

This PR fixes the assignment of pricing_group_keys/grouped_by on event_enriched_expanded when no charge_filter_id is nil

Copilot AI review requested due to automatic review settings March 3, 2026 14:01
Copy link

Copilot AI left a comment

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 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 PricingGroupKeys when 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 PricingGroupKeys are retained through ToDefaultFilter.

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.

@vincent-pochet vincent-pochet force-pushed the fix-pricing-group-keys branch from 93c4bdd to f9b5fbd Compare March 3, 2026 14:38
@vincent-pochet vincent-pochet force-pushed the fix-pricing-group-keys branch from f9b5fbd to 2a1b5db Compare March 3, 2026 16:19
@vincent-pochet vincent-pochet merged commit 2fec4db into main Mar 3, 2026
1 check passed
@vincent-pochet vincent-pochet deleted the fix-pricing-group-keys branch March 3, 2026 16:24
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
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.

3 participants