ISSUE DESCRIPTION Fail on HTTP Status 204 (No Content) Hello, I'm using Synadia Cloud…
- User
ISSUE DESCRIPTION
Fail on HTTP Status 204 (No Content) Hello,
I'm using Synadia Cloud which has a
DELETEAPI that returns a response with no body.$ restish synadia delete-nats-user --help Deletes a NATS user from an account ## Argument Schema: { user-id: (string) } ## Responses 204/400/401/403/404 Response has no bodyIn this case, it's expected to have an empty body. Nevertheless,
restishfails with the error:ERROR: Parse response error ERROR: Caught error: EOFHere is the full log:
DEBUG: API loading took 6.245709ms DEBUG: Configuration: [REDACTED] DEBUG: Adding TLS configuration DEBUG: Making request: DELETE /api/core/beta/nats-users/[REDACTED] HTTP/1.1 Host: cloud.synadia.com Accept: application/msgpack;q=0.8,application/cbor;q=0.9,application/ion;q=0.6,application/json;q=0.5,application/yaml;q=0.5,text/*;q=0.2,*/* Accept-Encoding: deflate, gzip, br Authorization: [REDACTED] User-Agent: restish-0.20.0 DEBUG: Got response from server in 426.428041ms: HTTP/2.0 204 No Content Content-Encoding: gzip Date: Mon, 26 May 2025 19:48:15 GMT Set-Cookie: [REDACTED] Strict-Transport-Security: max-age=15768000 ; includeSubDomains Vary: Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN DEBUG: Decoding response from gzip ERROR: Parse response error ERROR: Caught error: EOF DEBUG: goroutine 1 [running]: runtime/debug.Stack() /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/debug/stack.go:24 +0x68 github.com/danielgtaylor/restish/cli.Run.func1() /home/runner/work/restish/restish/cli/cli.go:849 +0x68 panic({0x1051c4f40, 0x140001900f0}) /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/panic.go:838 +0x204 github.com/danielgtaylor/restish/cli.MakeRequestAndFormat(0x1052d4830?) /home/runner/work/restish/restish/cli/request.go:568 +0x118 github.com/danielgtaylor/restish/cli.Operation.command.func1(0x14000693800?, {0x1400061e8a0, 0x1, 0x2}) /home/runner/work/restish/restish/cli/operation.go:142 +0x814 github.com/spf13/cobra.(*Command).execute(0x14000693800, {0x1400061e880, 0x2, 0x2}) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x5dc github.com/spf13/cobra.(*Command).ExecuteC(0x1400034e600) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x35c github.com/spf13/cobra.(*Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968 github.com/danielgtaylor/restish/cli.Run() /home/runner/work/restish/restish/cli/cli.go:857 +0x9a8 main.main() /home/runner/work/restish/restish/main.go:40 +0x370ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository using command. Additionally, you can use and to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I’ll trace the response decoding and formatting path around
MakeRequestAndFormat, locate existing HTTP response tests, and reproduce the 204-with-encoding case before making a focused fix. - Assistant
The stack trace reflects an older repository layout; the current checkout has no
cli/request.goat that path. I’ll inspect the actual tree and search by function/error strings instead. - Assistant
This checkout is a newer architecture than the reported version, so I’ll identify the current equivalent by searching request execution, content decoding, and body parsing code and then review repository-specific guidance.
- Assistant
The current code already has some 204 coverage, but the problematic combination is specifically an empty body plus
Content-Encoding: gzip: constructing a gzip reader on zero bytes returnsEOFbefore body parsing. I’ll inspect both central decoding implementations and their tests to ensure the fix applies consistently without masking malformed non-empty compressed responses. - Assistant
The defect is present in
output.decodeBody: it callsgzip.NewReaderbefore discovering that the transport body is empty. The CLI also has raw/stream helpers with the same ordering. Before changing code, I’ll reproduce through the built CLI against a local server returning exactly204,Content-Encoding: gzip, and zero bytes, while checking the command syntax. - Assistant
The initial reproduction was blocked by an unset Go module cache (
GOMODCACHE/GOPATH), not by the application. I’ll use a temporary GOPATH and rerun the same black-box reproduction. - Assistant
Dependencies downloaded successfully, but this environment also lacks
HOME/GOCACHE. I’ll explicitly set both temporary cache locations and complete the reproduction. - Assistant
The black-box reproduction confirms exit code 1 with
decompressing response: EOF. The safest semantic fix is to bypass decompression for responses that HTTP defines as bodyless (all 1xx, 204, 304, and HEAD responses), rather than treating any gzipEOFas success—which could hide truncated gzip responses. I’ll trace all normalization and raw-output entry points so one shared predicate can cover default and explicit print modes. - Assistant
There are three body-reading paths: normalized output, explicit raw output, and streaming detection. I’ll add a small HTTP-semantics helper in the internal output package and use it before selecting a content decoder in each path. It will only suppress bodies forbidden by protocol semantics, preserving errors for malformed/truncated compressed payloads on ordinary responses.
- Assistant
I’ll implement
ResponseCanHaveBodyusing RFC body rules and wire it into normalization and the CLI’s raw/stream decompression helpers. For bodyless responses, the streaming helper will still retain and close the original body, avoiding a resource leak while returning an empty reader. - Assistant
The focused change is in place. I’ll now rebuild and rerun the exact local 204/gzip reproduction, then test explicit raw-body output as a second path and verify that an ordinary
200with an empty gzip stream still errors (so corruption is not being silently accepted). - Assistant
The reported case now exits 0 with no output, explicit body printing also succeeds silently, and a body-capable 200 with invalid empty gzip still fails as intended. I’ll run the affected package tests and then the repository-wide fast suite.
- Assistant
All directly affected tests pass. I’ll now run the full fast suite to catch cross-package regressions, followed by the integration-tagged suite as required by the repository guidance for CLI behavior changes.
- Assistant
The full fast suite passes. I’ll run the integration suite now, then inspect the final diff/status and consider any lint or API-shape concerns before submission.
- Assistant
Both full suites pass. Final review confirms the helper matches Go/net/http’s body rules (1xx, 204, 304, plus HEAD), does not rely on
Content-Length, and keeps malformed gzip errors for statuses that may carry bodies. I’ll check that only the intended source files changed and review the complete patch before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.