Skip to content

test(billing): reproduce DLQ validation failures - #5045

Closed
turip wants to merge 5 commits into
mainfrom
feat/billing-dlq-regression-tests
Closed

turip wants to merge 5 commits into
mainfrom
feat/billing-dlq-regression-tests

Conversation

@turip

@turip turip commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add integration coverage for charge-backed usage lines whose feature meters disappear before collection
  • cover multiple missing-meter features and unrelated not-due usage charges
  • reproduce the EU failure where a draft.invalid partial invoice retains an active realization run and blocks final collection
  • describe the expected behavior: persist critical invoice validation issues instead of returning operational errors to the worker

Current status

This PR is intentionally draft and the new regression scenarios expose existing failures. The active-run case currently returns the same error observed in production: an active realization run already exists for this charge.

Verification

  • focused EU integration test reaches the expected failure point
  • focused fast Go lint passes with 0 issues
  • Go formatting and diff checks pass

No Jira ticket.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

Summary

  • Adds missing-meter integration scenarios for credit-only and credit-then-invoice charges.
  • Introduces cached lazy feature-meter resolution and lifecycle-aware charge references.
  • Treats invalid draft invoice states as failed and retryable.
  • Adds test helpers and assertions for charge status and validation behavior.

Diagram

sequenceDiagram
  participant Worker
  participant Billing
  participant Charge
  participant MeterResolver
  Worker->>Billing: Advance invoice
  Billing->>Charge: Advance usage charge
  Charge->>MeterResolver: Resolve meter lazily
  MeterResolver-->>Charge: Missing-meter validation issue
  Charge-->>Billing: Validation failure
  Billing-->>Worker: Invalid draft / retry outcome
Loading

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

ManagedBy: billing.SubscriptionManagedLine,
UniqueReferenceID: "usage-based-missing-meter-collection",
FeatureKey: apiRequestsTotal.Feature.Key,
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Unpaired frozen-clock changes

These clock changes are not immediately paired with defer clock.UnFreeze() in the same scope. A subtest failure can therefore leave the shared clock frozen until outer cleanup runs, weakening subtest isolation; the same pattern also occurs at lines 270, 352, and 493.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: test/credits/credit_then_invoice_test.go
Line: 199

Comment:
**Unpaired frozen-clock changes**

These clock changes are not immediately paired with `defer clock.UnFreeze()` in the same scope. A subtest failure can therefore leave the shared clock frozen until outer cleanup runs, weakening subtest isolation; the same pattern also occurs at lines 270, 352, and 493.

**Context Used:** AGENTS.md ([source](https://github.com/openmeterio/openmeter/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

@turip
turip force-pushed the feat/billing-dlq-regression-tests branch from 98c4e97 to f561198 Compare September 8, 2026 07:35
@turip
turip changed the base branch from main to feat/billing-line-engine-billability September 8, 2026 07:35
@turip
turip force-pushed the feat/billing-line-engine-billability branch from 19ea3e0 to b7c8d73 Compare September 8, 2026 14:09
Base automatically changed from feat/billing-line-engine-billability to main September 9, 2026 07:55
@turip
turip force-pushed the feat/billing-dlq-regression-tests branch from f561198 to ae14860 Compare September 9, 2026 08:26
@turip
turip force-pushed the feat/billing-dlq-regression-tests branch from 136ff43 to 1997978 Compare September 9, 2026 14:49
@turip turip added release-note/ignore Ignore this change when generating release notes release-note/bug-fix Release note: Bug Fixes and removed release-note/ignore Ignore this change when generating release notes labels Sep 9, 2026
@turip turip closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants