fix(gateway): honor 1 MiB POST /asap body cap - #86
Closed
cursor[bot] wants to merge 1 commit into
Closed
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Phase 5 allocated a 1 MiB dynamic buffer for POST /asap, but every POST/PUT still 413'd when Content-Length exceeded the 64 KiB static cap used by PUT /api/config. Peers sending legal envelopes in that range never reached parse. Skip the static cap when the dynamic /asap buffer is in use. Keep the 64 KiB limit for other POST/PUT routes. Point the over-max test at 1048577 (1 MiB + 1); 1000001 was still under ASAP_BODY_MAX. Co-authored-by: esadrianno <esadrianno@gmail.com>
3 tasks
5 tasks
Collaborator
|
Superseded by #97 (rewrite against current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HIGH: Phase 5 added a 1 MiB dynamic buffer for
POST /asap, but every POST/PUT still 413'd when Content-Length exceeded the 64 KiB static cap used byPUT /api/config. Legal ASAP envelopes in (64 KiB, 1 MiB] never reached parse.Distinct from inbound-server PRs #53 (unwired provider/tools) and #61 (response truncation).
Concrete trigger
A peer posts
state.query(or any allowed payload_type) with Content-Length 65537 to 1048576, for example a ~70 KiB JSON pad inpayload.asap_http_body_init_from_requestallocates the dyn buffer, thenhttp_callbackLWS_CALLBACK_HTTPoverwritesbody_too_largebecausecl > BODY_BUF_SIZE(65536).http_dispatch_bodyreturns 413 before JSON-RPC parse.task.requestwith a moderately large history or document hits the same gate.state.query/task.canceldo not need the provider wiring from #53.The existing
test_asap_body_over_maxused Content-Length1000001, which is still underASAP_BODY_MAX(1048576). It only 413'd because of this leftover 64 KiB check.Impact
Inbound ASAP HTTP rejects any envelope above 64 KiB even though the advertised/implemented cap is 1 MiB. Peers cannot deliver large
state.query/mcp.tool_call/task.requestbodies.Fix
Skip the static cap when the request is using the
/asapdynamic buffer (use_dyn_body). Keep the 64 KiB limit for other POST/PUT routes.Test plan
test_exceeds_static_cap— dyn buffer skips 64 KiB; static buffer still 413stest_asap_body_over_static_cap_accepted— ~70 KiBstate.queryreturns 200 withresult/sessionstest_asap_body_over_maxnow uses 1048577 (true 1 MiB + 1)GATEWAY=1test_asap_http_bodyandtest_gateway_http(with-Werror)