CommandCode returns errors as a type:"error" event inside an HTTP 200 NDJSON stream instead of a non-200 status, so the existing combo/account fallback logic (keyed off response.status) never triggered and the error text was streamed to the client as if it were content. Peek the first NDJSON events before committing to a stream; on a type:"error" event, abort and return a proper 4xx/5xx Response instead. Normal streams are replayed losslessly (buffered prefix + rest of the stream) through the existing translator, so the happy path is unchanged. Add CommandCodeExecutor.parseError() so parseUpstreamError() can extract a clean message/status from the synthesized error body.
6.3 KiB
6.3 KiB