A vendor's 413 that came after the stream's headers had gone out (a
keepalive sent while the vendor was quiet) reached Pi as a stream error
of type api_error saying "413 Request Entity Too Large". Pi compacts only
when the error's text says request_too_large (overflow.ts), so the turn
stopped. A 413 before the headers was already typed request_too_large
(writeErrorSaid, 97f264c7).
streamError, which every failure in a stream already begun goes through
(failTo and holdWriter's), appends "(request_too_large)" to the text of a
413 that isn't a context overflow and doesn't say it already; the Chat
and Anthropic encoders type that event request_too_large. Gemini keeps
its own status shape; an overflow stays context_length_exceeded.
Review change (on top of ggbdpq's 8a278645): the test matched
request_too_large anywhere in the body, so Chat's new type alone passed
it: with the text append taken out by hand it stayed green. It now reads
the error event's message (what Pi reads) and type. The new
TestStreamErrorByteCapInEveryShape runs streamError for Chat, Anthropic,
Responses and Gemini, and for a 413 that says the prompt is too long.
Run:
- With gateway.go, chat.go and anthropic.go put back: both tests FAIL.
With only the text append taken out: both FAIL. With only Anthropic's
type taken out: TestStreamErrorByteCapInEveryShape FAILs ("anthropic …
want "type":"request_too_large""). Restored: ok.
- TestBodyRejectionErrorShapes, TestStreamErrorSaysItPasses,
TestGroupLastFailureInStreamSaysItPasses: ok.
- Full suite, go test -tags nogui -timeout 45m ./... (set -o pipefail,
sandbox HOME, load ~350) at 0224e826f (these four commits on
ebf3f48f7) plus #2545's patch: every package ok except internal/agent,
whose one red (TestRekeyGivesWSLAgentTheSharingKey) is #2545's, which
was dropped (problems posted on #2545). internal/agent alone at
0224e826f: ok. Rebased on dccfefdf7 (#2635, internal/library only):
build, vet, internal/library ok. gofmt -l clean; go vet darwin (gui),
GOOS=linux and GOOS=windows -tags nogui: clean. GUI (i18n-keys,
gui-de/ja/zh-TW, import-*, key-import, login-import): all pass except
login-import's Chromium case, which fails the same alone on origin/main
ebf3f48f7 (#1307, output posted there).
Not tried: a real nginx 413 or a real Pi compacting after it.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>