fix(a2a): detect and fail loud on proxy body truncation (core#2677) #2686
Reference in New Issue
Block a user
Delete Branch "fix/a2a-proxy-body-truncation-2677"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes core#2677: A2A proxy request/response bodies were silently truncated by
io.LimitReader. This change detects oversize bodies and fails loud instead of cutting them mid-message, and raises the request cap from 1 MB to 16 MB and the response cap from 10 MB to 64 MB so normal spec-length delegations and large agent replies deliver intact.Changes
readBodyWithLimithelper that returns anerrA2ABodyTooLarge-wrapped error when a body exceeds its limit.truncated=trueandmax_bytesfor oversize A2A requests.truncated=true,max_bytes, anddelivery_confirmedfor oversize agent responses.maxProxyRequestBodyto 16 MB andmaxProxyResponseBodyto 64 MB.Fixes #2677.
SOP Checklist
a2a_proxy_truncation_test.gocovering the helper, oversize request 413 path, and a 16 MB request forwarded intact;go test ./internal/handlers/ -run 'TestReadBodyWithLimit|TestProxyA2A_RequestBodyTooLarge|TestProxyA2A_LargeRequestWithinLimit'passes.io.LimitReadersilently capping bodies; the fix detects the cap and returns a loud error instead of truncating.textutiltruncation helpers; no directly relevant memory feedback for this specific bug.APPROVED for head
8b0cc3a849.Verified this follow-up is scoped to the request-body read error branch on top of the already-merged #2681 truncation fix. Oversize request bodies still return 413 with truncated=true and max_bytes because errors.Is(err, errA2ABodyTooLarge) is checked explicitly; non-truncation read errors now return 400 with the read error instead of being mislabeled as truncation.
The #2681 behavior remains intact: readBodyWithLimit reads limit+1 and wraps errA2ABodyTooLarge on oversize, request/response caps remain 16MB/64MB, and response-body read failures still surface delivery_confirmed/truncated/max_bytes correctly. Diff is one file only. CI / Platform (Go) and CI / all-required are green, and the PR is mergeable=true; remaining red statuses are governance/SOP or advisory rather than required runtime failures.
/sop-ack