routing: add context to reloadPayment method
What changed, and why it matters
This commit replaces a placeholder 'context.TODO()' with a proper cancellation context in one internal payment-tracking method. It is a code-quality and graceful-shutdown improvement, not a fix for an active security vulnerability. There is no evidence of exploitability from the diff alone.
No immediate action required. Treat as routine maintenance. Review whether other context.TODO() or context.Background() calls in the payment lifecycle should similarly accept lifecycle contexts.
Security signals we found
Use of context.TODO() removed in favor of caller-supplied context
Database read now respects lifecycle cancellation context
Evidence from the diff
The patch changes paymentLifecycle.reloadPayment() to accept a context.Context argument instead of internally using context.TODO(). The caller in the main lifecycle loop passes cleanupCtx, allowing database reads to respect cancellation during shutdown. This is a defensive cleanup; it does not by itself prevent a specific attack or fix a known bug.
Changed components
routing/payment_lifecycle.gopaymentLifecycle.reloadPaymentControl.FetchPaymentInspect captured patch +3 / −4
diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go
index 763cf43..9be86dc 100644
--- a/routing/payment_lifecycle.go
+++ b/routing/payment_lifecycle.go
@@ -250,7 +250,7 @@ lifecycle:
}
// We update the payment state on every iteration.
- currentPayment, ps, err := p.reloadPayment()
+ currentPayment, ps, err := p.reloadPayment(cleanupCtx)
if err != nil {
return exitWithErr(err)
}
@@ -1163,11 +1163,10 @@ func (p *paymentLifecycle) reloadInflightAttempts(
}
// reloadPayment returns the latest payment found in the db (control tower).
-func (p *paymentLifecycle) reloadPayment() (paymentsdb.DBMPPayment,
+func (p *paymentLifecycle) reloadPayment(
+ ctx context.Context) (paymentsdb.DBMPPayment,
*paymentsdb.MPPaymentState, error) {
- ctx := context.TODO()
-
// Read the db to get the latest state of the payment.
payment, err := p.router.cfg.Control.FetchPayment(ctx, p.identifier)
if err != nil {
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.