Skip to content

Retry unresolved usage events before DLQ#751

Draft
RitwijParmar wants to merge 1 commit into
getlago:mainfrom
RitwijParmar:codex/lago-retry-unresolved-usage-events
Draft

Retry unresolved usage events before DLQ#751
RitwijParmar wants to merge 1 commit into
getlago:mainfrom
RitwijParmar:codex/lago-retry-unresolved-usage-events

Conversation

@RitwijParmar

@RitwijParmar RitwijParmar commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Usage events can arrive before the subscription cache or database view has caught up. Before this change, a non API post-processed event with an external subscription id but no active subscription match could be treated as successfully enriched without a subscription. That risks committing a billable usage event without producing the downstream enriched records needed for billing.

This PR changes that path to a retryable, non-capturable subscription_not_found failure while the event is still inside the retry window. If the event ages out, it goes to the dead letter topic with enough metadata to understand and replay it safely.

What changed:

  • Return subscription_not_found when a usage event has an external subscription id but no active subscription at the event timestamp
  • Replace the hard-coded retry-age check with a named retry window helper
  • Add DLQ metadata for retryable, capturable, event age, retry window, expired retry window, org id, subscription external id, transaction id, and metric code
  • Add tests for young unresolved events staying uncommitted and expired unresolved events going to DLQ with retry metadata

Validation

  • /tmp/codex-go/go/bin/gofmt -w on changed Go files
  • git diff --check

I also tried go test -vet=off ./processors/events_processor ./models from events-processor using a temporary Go toolchain. The local machine is almost out of disk space and the build failed before compiling these packages with no space left on device while writing Go build artifacts. The failure was environmental, not a test assertion failure.

@cla-check-bot

cla-check-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Welcome, @RitwijParmar!

Thanks for your first contribution!

Before we proceed with the review, please sign the Fiduciary License Agreement:

Sign the FLA

Once signed, this PR will be automatically updated.

@cla-check-bot

cla-check-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Thanks, @RitwijParmar! 🎉

Your CLA has been signed and is now on file. We'll proceed with the review shortly.

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