Skip to content

fix(ledger): raise /errors/asset-mismatch for CURRENCY on asset transfers - #122

Merged
ffroliva merged 2 commits into
mainfrom
fix/asset-mismatch-422
Nov 3, 2026
Merged

ffroliva merged 2 commits into
mainfrom
fix/asset-mismatch-422

Conversation

@ffroliva

@ffroliva ffroliva commented Nov 3, 2026

Copy link
Copy Markdown
Owner

What

/errors/asset-mismatch (spec §6.5, ErrorCode.ASSET_MISMATCH) was catalogued but never raised. assetClass: CURRENCY on PUT /api/v1/accounts/{a}/asset-transfers/{t} was accepted as a tax lot, so cash landed in a holding that the account balance never saw.

Fix

Account.transferAsset now returns a MovementRejected with reason asset-mismatch for CURRENCY. The existing rejection mapping turns it into a 422, and an idempotent replay returns the same 422.

Quantity.requireSameAsset stays an IllegalArgumentException. Holdings are keyed by (symbol, assetClass), so a request cannot reach that guard.

Tests

  • New AccountTest.cashThroughTheAssetTransferEndpointIsRejectedAsAssetMismatch. It failed before the fix (the transfer was accepted) and passes after.
  • Unit suite: 442 tests, 0 failures.

Spec bumped to 3.58 (§6.5 row, §2.5 note, changelog).

…fers

The §6.5 row and ErrorCode.ASSET_MISMATCH existed since 3.55 but nothing
produced them, and assetClass CURRENCY on PUT .../asset-transfers was
accepted as a tax lot: cash the balance never saw. It is now a recorded
MovementRejected (reason asset-mismatch), so it replays as the same 422.
Spec 3.58.
@ffroliva
ffroliva merged commit 40a2886 into main Nov 3, 2026
11 checks passed
@ffroliva
ffroliva deleted the fix/asset-mismatch-422 branch November 3, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant