Repository navigation
Create payment intents and order rows atomically #76
Description
Problem
LockPrice inserts orders one at a time before the transaction intent is created. A later invalid order, SQL failure, price overflow or backend intent failure can leave partial order rows. LockPrice errors are passed directly to JSON serialization, which can produce an unhelpful empty object.
Proposed change
Validate the full request before effects and create its local transaction/order set atomically, returning a stable error on failure with no orphaned partial intent.
Acceptance criteria
- Validate nonempty/duplicate orders and the complete batch before writes, then commit the transaction and orders as one local operation.
- Inject a failure at each order and intent write and reopen real SQLite to prove no partial rows remain.
- Define backend intent creation versus local persistence ownership and preserve uncertainty if an external side effect occurred; do not retry silently.
- Return a meaningful bounded HTTP error category/message rather than serializing a Go error object; preserve wallet-free preflight before every chain-related write.
Current evidence
confirmed partial-write and diagnostic defects; source inspection only, no new runtime reproduction. Backlog classification is based on source inspection; this issue does not claim a new runtime reproduction.
- internal/dispatcher/transport/api/handlers_payment.go: LockPrice writes each order during validation.
- internal/dispatcher/transport/api/handlers_payment.go: Orders are locked before CreatePaymentIntent is called, and errors are serialized directly.
- internal/dispatcher/payments/payments.go: CreateDummyIntent inserts its transaction independently.
Related work
These are integration points, not prerequisites for starting this issue.
- #77 — Define exact pricing units and reject overflow before persistence
- #3 — Return a consistent typed HTTP error envelope
Priority context
Improves both TEST bookkeeping and future payment correctness; it does not authorize monetary use.
Validation must use owned local fixtures on supported Linux environments. Record the implementing merge request and relevant test results before closing this issue.
Imported from GitLab issue 75. Originally opened 2026-09-10. Historical GitLab links may require access to the original project.
Activity
vincent10400094 commentedon Sep 25, 2026
Progress: #180, merged into
devvia #228 (e4a621f), validates and prices the whole batch before any write, refuses empty and duplicate batches, and returns typed errors. Still open: the orders and the intent are still written separately, with no failure injection at each write on real SQLite and no decision on who owns the backend intent.ctfbruce commentedon Oct 5, 2026
Implemented in #373. Payment intents validate the complete batch before persistence and store the intent, orders and owner atomically. SQLite failure tests cover transaction, order and owner writes, including reopened-file rollback checks. Errors use bounded HTTP responses, and USDC intent creation performs no chain call. CI passed all 16 checks.