Fall back to the collection account only on infrastructure failures - #4582
Merged
TaprootFreak merged 2 commits intoAug 1, 2026
Merged
Conversation
The collection-account fallback swallowed every issuance error with `.catch(() => null)`, including the authoritative KYC rejection that issuance raises under its own lock against the freshly loaded, merge-resolved owner. The fallback then re-checked only the request's own, possibly stale KYC-50 snapshot, so a customer the locked check had just rejected could still receive a usable collection account with a reference. Only degrade to the fallback on an infrastructure failure; re-throw business rejections (BadRequestException, above all KYC_REQUIRED) so they reach the caller. Applies to both the explicit and the implicit Frick issuance paths. A test covers the discrepancy case.
Cover the explicit personal-IBAN path with the same business-rejection test the implicit path already has: a KYC_REQUIRED raised by issuance for a level-50 request must reach the caller and never reach the collection-account fallback. Move the infrastructure-vs-business helper above the fallback method so each comment sits directly over the method it describes.
Collaborator
Author
|
Two review passes to reach zero findings.
All checks green; buy.service.spec 50 tests green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4580. The collection-account fallback there caught issuance failures with
.catch(() => null), which is too broad.Problem
Personal Frick IBAN issuance re-reads and merge-resolves the account owner under its own lock and raises
KYC_REQUIREDauthoritatively against that fresh owner. The blanket.catch(() => null)swallowed that rejection, and the fallback then re-checked only the request's ownselector.userDataKYC snapshot. When that snapshot is stale relative to the locked check — an in-flight KYC downgrade, or a merge whose target owner sits below level 50 — a customer the authoritative check had just rejected could still be handed a usable collection account with a valid reference. The same blanket catch also swallowedCURRENCY_UNSUPPORTEDand other business rejections.Change
Tell the two failure kinds apart. An infrastructure failure (the provider is down) is what the fallback exists for and still degrades to
null. A business rejection is aBadRequestException— above allKYC_REQUIRED— and is re-thrown so it reaches the caller. Applies to both the explicit and the implicit Frick issuance paths, via a small shared helper.Verification
A new test covers the discrepancy case: issuance rejects with
KYC_REQUIREDwhile the request snapshot is level 50 → the request rejects withKYC_REQUIREDand the fallback (getBank) is never reached.tsc, ESLint, Prettier clean;buy.service.spec.ts49 tests green locally.