Repository navigation
fix(billing): make line engine lifecycle steps atomic - #5247
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughBilling runs invoice and payment line-engine callbacks in transaction attempts. Warning-only validation results can commit, while critical validation issues and system errors roll back. Direct-paid authorization and settlement share an attempt. Tests cover rollback, retries, and historical partial state. ChangesBilling transaction attempts
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant InvoiceState
participant StepRunner as runLineEngineInvoiceSteps
participant Tx as transaction.Run
participant LineEngines
InvoiceState->>StepRunner: invoice and ordered callback steps
StepRunner->>Tx: execute grouped line-engine steps
Tx->>LineEngines: invoke callbacks
LineEngines-->>Tx: callback result or validation error
Tx-->>StepRunner: result, warnings, or transaction error
StepRunner-->>InvoiceState: assign invoice after successful attempt
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No concrete merge-blocking issue was identified in the reviewed changes. Normal CI checks should still confirm that the billing service package compiles. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change strengthens financial-state consistency by rolling back failed booking attempts across all participating lines and engines. No new authorization bypass or financial-integrity weakness was established in the reviewed paths. Deployment-specific behavior and engine extensions remain incompletely verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Overview
Line-engine lifecycle callbacks could commit earlier line or engine writes before a later callback returned a critical validation issue. This change runs each invoice-issued, payment-authorized, and payment-settled attempt in one billing-owned transaction across all live lines and engines.
Warning-only validation results still commit and are returned to the invoice. Critical validation issues roll back the line-engine writes before the retryable invoice failure is persisted, while system errors abort the operation. Direct-paid invoices run authorization and settlement in the same attempt.
The existing retry coverage remains for historical partial database state written before this atomicity guarantee, and the relevant billing documentation now describes the transaction boundary.
Notes for reviewer
make test-nocachepasses with 9156 tests and 9 skips.go vetpass for the affected billing code.Summary by CodeRabbit
The transactional change has no newly identified defect, but the outstanding repository test-comment requirement must be satisfied before merging.
Fix with agent prompt
Summary
The PR makes invoice-issued and payment callbacks transactional across live lines and engines, preserving warning-only results while rolling back failed attempts. It also adds rollback and historical-retry coverage and updates billing documentation.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Start line-engine attempt] --> B[Run callbacks in billing transaction] B --> C{Result} C -->|Success or warnings| D[Commit and retain warnings] C -->|Critical validation issue| E[Roll back line-engine writes] E --> F[Persist retryable failed invoice state] C -->|System error| G[Roll back and abort operation]Reviews (4) · Last reviewed commit: "chore: fix lo.Empty"