Problem
A single malformed amount in an uploaded batch crashes summary generation
and wipes out the row-level validation results that had already been
computed — leaving the user with a generic error instead of the specific
row that needs fixing.
Severity: Medium
Location: lib/stellar/summary.ts:7-20, contexts/BatchFlowContext.tsx:296-321,327-340
Description
getBatchSummary calls totalAmount.plus(instruction.amount) using
big.js before calling validatePaymentInstruction on that same
instruction. An amount like "not-a-number" throws immediately inside
big.js, before validation gets a chance to flag it as an ordinary invalid
row. In handleFileSelect
(contexts/BatchFlowContext.tsx:372-389), setValidationResult(parsed) is
called first with correct row-level data, but the subsequent
getBatchSummary throw is caught by the surrounding try/catch, which then
calls setValidationResult(null) — discarding the already-correct
validation data — and shows a generic "Failed to parse payment file" toast.
handleManualContinue (contexts/BatchFlowContext.tsx:392-406) calls
getBatchSummary with no surrounding try/catch at all, so the same input
would throw uncaught on that path.
Steps to Reproduce
- Upload an otherwise valid CSV with one row containing
amount=not-a-number.
parsePaymentFile correctly returns row-level validation info,
including the specific bad row.
getBatchSummary throws before that validation info is surfaced.
- The UI clears the validation result and shows only a generic parse
error — the actionable per-row error is lost.
Expected Behavior
A malformed amount should behave as an ordinary invalid row; valid rows and
the summary for them should remain visible and usable for review/correction.
Suggested Fix Approach
Validate each instruction before performing arithmetic on it, and sum only
already-validated amounts — or wrap the per-row arithmetic in its own
try/catch that preserves the parser's validation result instead of
discarding it.
Acceptance Criteria
Problem
A single malformed amount in an uploaded batch crashes summary generation
and wipes out the row-level validation results that had already been
computed — leaving the user with a generic error instead of the specific
row that needs fixing.
Severity: Medium
Location:
lib/stellar/summary.ts:7-20,contexts/BatchFlowContext.tsx:296-321,327-340Description
getBatchSummarycallstotalAmount.plus(instruction.amount)usingbig.jsbefore callingvalidatePaymentInstructionon that sameinstruction. An amount like
"not-a-number"throws immediately insidebig.js, before validation gets a chance to flag it as an ordinary invalidrow. In
handleFileSelect(
contexts/BatchFlowContext.tsx:372-389),setValidationResult(parsed)iscalled first with correct row-level data, but the subsequent
getBatchSummarythrow is caught by the surroundingtry/catch, which thencalls
setValidationResult(null)— discarding the already-correctvalidation data — and shows a generic "Failed to parse payment file" toast.
handleManualContinue(contexts/BatchFlowContext.tsx:392-406) callsgetBatchSummarywith no surrounding try/catch at all, so the same inputwould throw uncaught on that path.
Steps to Reproduce
amount=not-a-number.parsePaymentFilecorrectly returns row-level validation info,including the specific bad row.
getBatchSummarythrows before that validation info is surfaced.error — the actionable per-row error is lost.
Expected Behavior
A malformed amount should behave as an ordinary invalid row; valid rows and
the summary for them should remain visible and usable for review/correction.
Suggested Fix Approach
Validate each instruction before performing arithmetic on it, and sum only
already-validated amounts — or wrap the per-row arithmetic in its own
try/catch that preserves the parser's validation result instead of
discarding it.
Acceptance Criteria
the rest of the batch
handleManualContinueno longer throws uncaught on a malformed manualentry
amount