Files
redshift 6a8194e4d1 fix(ehbp): relay encrypted enclave error responses verbatim
EHBP encrypts response bodies, error bodies included. On a non-200 the
proxy decoded the ciphertext as UTF-8 and wrapped it in its own JSON
error envelope, so callers saw mojibake instead of the enclave's actual
reason (a real-world 404 caused by an upstream model id surfaced only as
`EHBP upstream tinfoil returned 404 ... <binary garbage>`), and the
provider status was lost behind the 424 mapping.

When the enclave response carries `Ehbp-Response-Nonce`, reconstruct the
reply verbatim -- status, nonce header and ciphertext body -- and raise
`EhbpEncryptedUpstreamError`. Failover, cooldown accounting and
reservation release are unchanged; once the provider chain is exhausted,
`proxy.py` returns the enclave reply instead of a proxy envelope, and the
EHBP client decrypts the provider's real error.

Already-plaintext non-200s (router/gateway rejections without a nonce)
keep the existing structured-error handling. X-Cashu requests refund the
token and relay the ciphertext together with the `X-Cashu` refund header.

Ciphertext is also kept out of the proxy's error logs and messages; the
log line records the byte count instead.
2026-10-17 17:18:20 +00:00
..
2026-01-24 17:55:45 +08:00