Skip to content

Cap wire response bodies inside hey-sdk #248

Description

@jeremy

What

The generated parsers in `hey-sdk/go` read every response body with `io.ReadAll` before anything in the CLI can apply a budget. A server that answers one entries page or one message with gigabytes is a memory exhaustion, and nothing in the SDK bounds it.

hey-cli installs an interim guard: a `RoundTripper` via `hey.WithHTTPClient` that caps decompressed success and error bodies before the generated parsers see them (`internal/cmd/sdk.go`). That keeps the CLI's boundary where it was, but it is the CLI patching the SDK's contract from outside.

Ask

Add the cap to `basecamp/hey-sdk` itself — a per-operation or client-wide maximum body size, defaulting to something generous, enforced in the transport so every consumer gets it — and then remove the CLI-side wrapper.

Reproduction

Point the CLI at a server that answers `/messages/.json` with an unbounded stream; without the wrapper `hey threads ` grows until the process is killed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions