Preserve bounty payout metadata when creating payment#265
Preserve bounty payout metadata when creating payment#265BogdanMaryniuk wants to merge 1 commit into
Conversation
Greptile SummaryThis PR merges pre-existing
Confidence Score: 5/5Safe to merge — the production code change is a three-line, well-guarded spread that correctly preserves audit metadata while letting fresh payment fields win on collision. The implementation correctly guards against null, array, and primitive values before spreading, and the spread order guarantees new payment fields always override stale ones. The test adds useful regression coverage for the preservation case, though it stops short of asserting the override behavior for conflicting keys. route.test.ts — the fixture could include a conflicting key to pin the override guarantee. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Route as POST /pay route
participant DB as Supabase (bounty_submissions)
participant CP as CoinPayPortal
Client->>Route: POST request
Route->>DB: SELECT submission (includes metadata)
DB-->>Route: "submission { metadata: { expired_coinpay_invoice_id, expired_at, ... } }"
Note over Route: Compute existingMetadata (guard against null/array)
Route->>CP: createPayment(...)
CP-->>Route: "{ payment_id, address, amount_crypto, expires_at, ... }"
Note over Route: Merge: { ...existingMetadata, payment_address, amount_crypto, expires_at, ... }
Route->>DB: "UPDATE { payout_status, coinpay_invoice_id, pay_url, metadata: merged }"
DB-->>Route: "{ error: null }"
Route-->>Client: "200 { data: { payment_address, ... } }"
Reviews (1): Last reviewed commit: "Preserve bounty payout metadata" | Re-trigger Greptile |
| metadata: { | ||
| expired_coinpay_invoice_id: "cp-pay-expired-1", | ||
| expired_at: "2026-05-22T12:00:00Z", | ||
| reviewer_note_id: "review-note-1", | ||
| }, |
There was a problem hiding this comment.
The regression fixture only contains non-conflicting metadata keys (
expired_coinpay_invoice_id, expired_at, reviewer_note_id). The PR description states "new payment details take precedence," but no assertion verifies that a stale payment_address or expires_at carried in existingMetadata is actually overridden by the new payment values. Adding one conflicting key (e.g., an old payment_address) would make this guarantee explicit and guard against future refactors that accidentally flip the spread order.
| metadata: { | |
| expired_coinpay_invoice_id: "cp-pay-expired-1", | |
| expired_at: "2026-05-22T12:00:00Z", | |
| reviewer_note_id: "review-note-1", | |
| }, | |
| metadata: { | |
| expired_coinpay_invoice_id: "cp-pay-expired-1", | |
| expired_at: "2026-05-22T12:00:00Z", | |
| reviewer_note_id: "review-note-1", | |
| // Stale payment field from the previous invoice — should be overridden | |
| payment_address: "stale-address-should-be-overridden", | |
| }, |
Summary
Tests