Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
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. Comment |
| require.Equal(t, component, issues[0].Component) | ||
| require.Contains(t, issues[0].Message, "unsupported operation") | ||
| // TODO: Add invoice-line context assertions when line engines attach invoice and line ID attributes. | ||
| assert.Contains(t, issues[0].Message, "invoice_issued") |
There was a problem hiding this comment.
These tests run in the ordinary go test ./... CI job, but the production fixes they expect are not in this PR. Here, validation conversion drops the wrapped invoice_issued context, so the assertion fails. The new credit lifecycle tests also assert recovery behavior that the PR documents as still broken. Without gating the reproducers or landing the fixes, the normal CI test job fails.
Prompt To Fix With AI
This is a comment left during a code review.
Path: openmeter/billing/charges/statemachine/machine_test.go
Line: 188
Comment:
**Ungated reproducers fail CI**
These tests run in the ordinary `go test ./...` CI job, but the production fixes they expect are not in this PR. Here, validation conversion drops the wrapped `invoice_issued` context, so the assertion fails. The new credit lifecycle tests also assert recovery behavior that the PR documents as still broken. Without gating the reproducers or landing the fixes, the normal CI test job fails.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.cab7dc8 to
406e8ca
Compare
| require.Equal(t, billing.StandardInvoiceStatusDraftWaitingForCollection, invoice.Status) | ||
| // The clock stores one global frozen value, so restore the caller's test time. | ||
| callerTime := clock.Now() | ||
| clock.FreezeTime(invoice.DefaultCollectionAtForStandardInvoice()) |
There was a problem hiding this comment.
Clock freeze lacks scoped cleanup
setupChargeBookingInvoice freezes the global clock here but restores the caller’s time only after AdvanceInvoice succeeds. The later freezes in TestIssuingSkipsDeletedChargeLine and TestIssuingFailedInvoicePreservesUnsupportedCorrectionHistory follow the same pattern. Repository guidance requires each clock.FreezeTime(...) to be paired immediately with defer clock.UnFreeze() in the same scope. Please satisfy that requirement before merging while preserving the caller’s frozen test time.
Context Used: CLAUDE.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/credits/credit_then_invoice_issuing_test.go
Line: 264
Comment:
**Clock freeze lacks scoped cleanup**
`setupChargeBookingInvoice` freezes the global clock here but restores the caller’s time only after `AdvanceInvoice` succeeds. The later freezes in `TestIssuingSkipsDeletedChargeLine` and `TestIssuingFailedInvoicePreservesUnsupportedCorrectionHistory` follow the same pattern. Repository guidance requires each `clock.FreezeTime(...)` to be paired immediately with `defer clock.UnFreeze()` in the same scope. Please satisfy that requirement before merging while preserving the caller’s frozen test time.
**Context Used:** CLAUDE.md ([source](https://github.com/openmeterio/openmeter/blob/main/CLAUDE.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.406e8ca to
229e4a2
Compare
Overview
Add regression coverage for invoice advancement failures and recovery from lifecycle progress persisted before line-engine attempts became atomic.
The tests now separate current behavior from historical recovery:
TODO.mdgroups the remaining work by lifecycle boundary and records which earlier failures are now fixed onmain.Notes for reviewer
This remains a draft containing reproducers and follow-up work. Production fixes for the intentionally failing recovery and diagnostics cases are still pending.
Validation:
The PR is not ready to merge because its ungated, intentionally failing reproducers still break the ordinary test run.
Fix with agent prompt
Summary
This PR adds billing lifecycle regression tests and a TODO describing recovery work. The tests distinguish atomic rollback in current attempts from explicitly recreated historical partial progress; several recovery and diagnostic reproducers remain intentionally failing.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Invoice lifecycle attempt] --> B{Line-engine result} B -->|Success or warnings| C[Commit attempt] B -->|Critical issue| D[Roll back attempt] D --> E[Persist retryable failed invoice] E --> F[Retry against historical progress]Reviews (3) · Last reviewed commit: "test(billing): align retry reproducers w..."