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 +0x370Interface
No new interfaces are introduced.
ADDITIONAL 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 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 inspect the request/response formatting path and existing tests, then reproduce the empty gzip-encoded 204 behavior before making the smallest compatible fix.
- Assistant
The repository layout differs from the paths in the historical stack trace, so I’ll locate the current Go sources and module root first.
- Assistant
I found a reorganized codebase. I’ll read its contributor guidance and trace response decoding from the current execution tests and implementation.
- Assistant
There are two paths: buffered output (
internal/output/response.go) and HTTP preprocessing (internal/cli/http.go). I’ll inspect both plus focused tests to identify where an empty gzip body producesEOFand where status 204 should short-circuit safely. - Assistant
The failure is reproduced structurally in
decodeBody: it constructs a gzip reader before checking emptiness, andgzip.NewReaderreturnsEOFfor a zero-byte body. HTTP 204 responses are bodyless by definition, so normalization should skip content decoding before consulting a stale/incorrectContent-Encodingheader. I’ll inspect test conventions and all normalization call sites to ensure this also covers raw/stream modes appropriately. - Assistant
The normal buffered path needs a semantic body check. To cover the CLI’s raw and streaming branches too, I’ll inspect the dispatch around those helpers; a centralized HTTP “response permits body” predicate may be preferable to patching only one decoder.
- Assistant
I’ll now run a temporary standalone reproducer (not a repository test) that creates the reported 204 +
Content-Encoding: gzip+ empty body response and calls the production normalizer. This should confirm the exactEOFfailure before editing. - Assistant
The reproducer could not build because this sandbox has neither
GOPATHnorGOMODCACHEconfigured. I’ll set an ephemeral module cache under/tmpand rerun without changing repository configuration. - Assistant
Dependencies downloaded successfully, but Go also requires a build cache and this sandbox has no
HOME. I’ll provide temporaryHOMEandGOCACHEpaths and rerun. - Assistant
The reproducer confirms the exact error. The most general fix is in
Registry.Decompress: detect a truly empty stream before selecting/initializing any content decoder. This matches the existing downstream intent (decodeBodyalready treats zero decoded bytes as valid), fixes normal, raw, and streaming paths, and handles staleContent-Encodingvalues beyond gzip without hard-coding status 204. I’ll inspect imports and apply that focused change. - Assistant
bufioandioare already imported, so no new dependencies are needed. I’ll buffer one byte only for encoded responses; on immediateio.EOF, return that empty buffered reader unchanged, otherwise pass the buffered reader to the registered decoder so the peeked byte is preserved. - Assistant
The same reproducer now returns a normalized 204 with nil body and no error. I’ll remove the temporary script, run the directly affected content/output/CLI packages, then run the full non-integration suite.
- Assistant
All directly affected package tests pass. I’ll run
go test ./...now to catch regressions elsewhere, particularly callers of the shared content registry. - Assistant
The complete fast suite passes. Since this affects CLI response behavior, repository guidance requests the integration-tag suite as final verification; I’ll run it, then inspect the final diff/status for accidental files.
- Assistant
Both fast and integration suites pass. I’ll perform the final hygiene review: confirm only the intended source file changed, check whitespace, and review the complete patch before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.