[BTAPI-70] Fix Wealthsimple externalId instability across pending→posted #80
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bug/BTAPI-70"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ticket
BTAPI-70 Wealthsimple canonicalId is not stable across pending→posted; every settling charge duplicates
Summary
canonicalIdon settlement, so the sync engine's dedupe key (previously the rawcanonicalId) missed on the posted variant and inserted a duplicate transaction instead of revising the pending row in place — the same miss also fired spuriouswealthsimplePendingVanishedalerts.deriveExternalId(server/lib/wealthsimple/external-id) to derive a stable dedupe key from the structurally-fixed portion ofcanonicalId, falling back to the raw id (logged) on any unrecognized shape. The rawcanonicalIdis now carried alongside onTransactionfor traceability.ws:migrate-external-idsCLI to re-deriveexternalIdon existing rows written before this fix — must be run once, with thesynccontainer stopped, before the next scheduled sync (see the updated rootCLAUDE.mdandserver/lib/wealthsimple/CLAUDE.mdfor the exact runbook).Known limitations (flagged, not fixed — out of scope for this ticket)
AlertKindand wiring, which is a genuine scope increase. Worth a follow-up ticket if it's ever seen in practice.WealthsimpleSyncState.reportedMissingExternalIds(still raw ids after migration) — self-correcting on the next tick (at most one duplicate vanished-pending alert), not worth the added migration scope.