core, tests: give the badge timeout its own message

This commit is contained in:
shum
2026-08-27 10:28:26 +00:00
parent f20856392b
commit 7e07426e69
2 changed files with 28 additions and 3 deletions
+12 -1
View File
@@ -5479,7 +5479,18 @@ sendBadgeRequest nm user signKey req =
pure $ either (badgeRequestFailed . responseFailed) id $ J.eitherDecodeStrict' respData
-- a sentence first, then the error itself: the apps render an 'internal' code by showing this
-- message (G2), and a bare 'Show' of a 'ChatError' is not something to put in front of a user
requestFailed e = "The badge service could not be reached, and the request was not delivered. Details: " <> tshow e
--
-- the agent's request timeout gets its own sentence, because it is the ONE outcome here that
-- may have been DELIVERED: the service can have received the request and consumed the code,
-- with only the reply lost. Saying "not delivered" would steer the user into re-entering the
-- same code, and 'redeemBadgeCode' mints a FRESH purchase key per call, so the retry reaches
-- the service as a different signer and is answered @code_used@ (plan §9) — burning a code
-- they paid for. Everything else this collapses is a genuine non-delivery: an unresolvable
-- target, a transport failure before the send, or an agent error other than the timeout.
requestFailed = \case
ChatErrorAgent {agentError = AGENT (A_SERVICE ASETimeout)} ->
"The badge service did not answer in time. The request may still have been delivered, so a code presented with it may already have been used, and entering it again will not help. Please contact support."
e -> "The badge service could not be reached, and the request was not delivered. Details: " <> tshow e
responseFailed e = "The badge service answered with something this app version cannot read. Details: " <> T.pack e
badgeRequestFailed e = BSPError {code = BSEInternal, message = Just e, retryAfter = Nothing}