Files
CLIProxyAPI/internal/runtime/executor/helps/codex_response_event_test.go
sususu98 20df0c25b2 fix(codex): preserve string errors and recognize untyped failures
Normalize string websocket errors without discarding their messages. Recognize untyped and body-wrapped failures across SSE, websocket, and duplex paths while retaining status, headers, and sequence numbers.

Cover transport and format combinations, replay invalidation, credential status precedence, and Responses framing with regression tests.
2026-11-16 12:28:56 +08:00

27 lines
1.0 KiB
Go

package helps
import "testing"
func TestCodexResponseEventType(t *testing.T) {
for _, tc := range []struct{ payload, want string }{
{`{"error":{"code":"bio_policy"}}`, "error"},
{`{"body":{"error":"blocked"}}`, "error"},
{`{"response":{"error":{"code":"bio_policy"}}}`, "error"},
{`{"code":"bio_policy","message":"blocked"}`, "error"},
{`{"error":null}`, ""},
{`{"error":" "}`, ""},
{`{"body":{"error":null}}`, ""},
{`{"response":{"error":null,"status":"completed"}}`, ""},
{`{"message":"This content was flagged for possible biological risk."}`, ""},
{`{"type":"response.output_text.delta","delta":"blocked","error":{"code":"bio_policy"}}`, "response.output_text.delta"},
{`{"type":"response.metadata","body":{"error":{"code":"bio_policy"}}}`, "response.metadata"},
{`{"error":{"code":"bio_policy"}}` + "trailing data", ""},
} {
t.Run(tc.payload, func(t *testing.T) {
if got := CodexResponseEventType([]byte(tc.payload)); got != tc.want {
t.Fatalf("type = %q, want %q", got, tc.want)
}
})
}
}