feat(realunit): surface price-source (Aktionariat) outage as 503 on buy/sell quote#3825
Open
TaprootFreak wants to merge 1 commit into
Open
feat(realunit): surface price-source (Aktionariat) outage as 503 on buy/sell quote#3825TaprootFreak wants to merge 1 commit into
TaprootFreak wants to merge 1 commit into
Conversation
…uy/sell quote When the external RealUnit price provider (Aktionariat) is down, the buy and sell payment-info endpoints used to leak a generic 500, so clients could not tell the failure apart from any other error. Wrap the price-dependent quote calls in getPaymentInfo/getSellPaymentInfo: on failure, if the live price is currently unavailable, throw a 503 PriceSourceUnavailableException with code PRICE_SOURCE_UNAVAILABLE so the apps can show an explicit "price provider unavailable" message; otherwise the original error is rethrown unchanged. The /v1/realunit/price endpoints are unchanged (still 200 + null) so the price chart keeps rendering history during the outage.
2 tasks
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.
Problem
When the external RealUnit price provider (Aktionariat) is unavailable, the buy and sell payment-info (quote) endpoints leak a generic
500. Clients cannot distinguish this from any other failure, so the apps can only show a generic "something went wrong, contact support" message — even though the cause is an external provider outage, not the app or DFX.Change
PriceSourceUnavailableException(HTTP 503,code: 'PRICE_SOURCE_UNAVAILABLE'), following the existing coded-exception pattern (buy-exceptions.ts,tfa-required.exception.ts). 503 matches the contract already used by the buy confirm flow.RealUnitService.getPaymentInfo(buy) andgetSellPaymentInfo(sell): wrap the price-dependent quote call in a smallwithPriceSourceGuardhelper. On failure, if the live RealUnit price is currently unavailable (getRealUnitPrice().chf == null), rethrow as the 503; otherwise the original error is rethrown unchanged (no masking of real 500s/validation errors)./v1/realunit/priceand/price/historyare unchanged (still200+ null), so the price chart keeps rendering history during the outage.The mobile apps map
statusCode == 503/code == PRICE_SOURCE_UNAVAILABLEto an explicit "price provider unavailable" message (separate app PR).Tests
realunit.service.spec.ts: guard rethrows asPriceSourceUnavailableException(503 + code) when the price is unavailable; rethrows the original error when the price is available; passes results through on success.npm run lint,npm run format:check,npm run build,npm run testall green.Test plan
PUT /v1/realunit/buyandPUT /v1/realunit/sellreturn503 {code: PRICE_SOURCE_UNAVAILABLE}.