SIGN IN SIGN UP

fix(api): return 413 instead of 200 when export refuses an oversized payload (#1422)

api::export always returned status_code 200, even when mem::export
detected the response would exceed the transport frame limit and
returned its {success:false, oversized:true, ...} refusal object
instead of the export data. A caller checking only the HTTP status
saw a normal successful export and could write out the tiny refusal
object as if it were a real backup.

Detect the refusal shape in the api::export trigger and return 413
with the refusal body, matching the pattern api::mesh-export already
uses for the same guard. mem::export itself is unchanged: it still
returns 200 for a real export and the refusal object for an oversized
one, the HTTP layer just now reports the right status.

The MCP standalone proxy's memory_export path called handle.call(),
which throws on any non-2xx response and let the generic proxy-error
handler in handleToolCall silently fall back to local in-memory KV
data, masking the refusal behind a small, unrelated response instead
of surfacing it. rest-proxy.ts now throws a ProxyCallError carrying
the parsed response body, and the memory_export case in standalone.ts
returns that body directly instead of letting it fall through to the
local-KV fallback. Every other proxied tool keeps its existing
fallback-on-error behavior unchanged.

The viewer does not call /agentmemory/export, so no viewer change is
needed. mcp/server.ts's in-process memory_export handler calls
mem::export directly and always wraps the result as MCP text content
regardless of shape, so it already surfaces the refusal and needed no
change.
R
Rohit Ghumare committed
00411d63f5d91546625859b55400774e99147b5b
Parent: e69a606
Committed by GitHub <noreply@github.com> on 9/28/2026, 6:39:01 AM