Skip to content

feat(realunit): surface price-source (Aktionariat) outage as 503 on buy/sell quote#3825

Open
TaprootFreak wants to merge 1 commit into
developfrom
feature/realunit-price-source-unavailable-503
Open

feat(realunit): surface price-source (Aktionariat) outage as 503 on buy/sell quote#3825
TaprootFreak wants to merge 1 commit into
developfrom
feature/realunit-price-source-unavailable-503

Conversation

@TaprootFreak
Copy link
Copy Markdown
Collaborator

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

  • New 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) and getSellPaymentInfo (sell): wrap the price-dependent quote call in a small withPriceSourceGuard helper. 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/price and /price/history are unchanged (still 200 + null), so the price chart keeps rendering history during the outage.

The mobile apps map statusCode == 503 / code == PRICE_SOURCE_UNAVAILABLE to an explicit "price provider unavailable" message (separate app PR).

Tests

  • realunit.service.spec.ts: guard rethrows as PriceSourceUnavailableException (503 + code) when the price is unavailable; rethrows the original error when the price is available; passes results through on success.
  • Local: npm run lint, npm run format:check, npm run build, npm run test all green.

Test plan

  • With the price source unavailable, PUT /v1/realunit/buy and PUT /v1/realunit/sell return 503 {code: PRICE_SOURCE_UNAVAILABLE}.
  • With the price available, quotes behave exactly as before.
  • Non-price errors (KYC/registration/validation) are unaffected.

…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.
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