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, locate relevant tests, and first reproduce the 204/empty gzip behavior with the smallest existing test surface possible.
- Assistant
The current repository appears to have been reorganized from the stack trace’s older
clilayout, and the initial exact-string search found nothing. I’ll inspect Go packages and search broadly for response parsing, compression, and EOF handling to identify the modern equivalent. - Assistant
The likely failure can occur at two layers: constructing a gzip reader over a truly empty 204 body, or decoding an empty decompressed payload as JSON. I’ll inspect both the content registry and the CLI’s buffered/streaming response paths, along with existing tests around empty responses.
- Assistant
There is already normalization behavior for an empty uncompressed 204, so the reported edge case is specifically the invalid combination
Content-Encoding: gzipwith zero wire bytes. I’ll read the complete normalization implementation and its tests to verify where decompression occurs and establish the expected representation (Body == nil, emptyRaw). - Assistant
The default bounded path calls
gzip.NewReaderbefore checking whether decompressed content is empty, which reproduces the reported EOF. The principled fix is to recognize HTTP responses that cannot contain a message body (HEAD, 1xx, 204, 304) before content decoding. I’ll also inspect raw-output and metadata helpers so the fix applies consistently across output modes rather than only the default formatter. - Assistant
All body-consuming paths can hit the same malformed header/body combination. I’ll create a temporary in-repository reproducer (not a test file), confirming that normalization currently returns
decompressing response: EOF; then I’ll remove it before editing. This also verifies the issue against the current codebase rather than relying only on the historical stack trace. - Assistant
The reproducer could not compile because this environment has both
GOMODCACHEandGOPATHunset, not because of repository code. I’ll inspect the project guidance and Go environment, then set a temporary standard cache path for all subsequent Go commands. - Assistant
I’ll rerun the same temporary reproducer with
GOPATH=/tmp/goandGOMODCACHE=/tmp/go/pkg/mod. Dependency downloads may take a moment, but this should produce the actual pre-fix behavior. - Assistant
Go additionally requires
GOCACHEbecauseHOMEis unset. I’ll set it explicitly and rerun; the temporary source was removed by the previous shell sequence, so I’ll recreate and clean it again. - Assistant
The pre-fix reproducer now confirms the exact
decompressing response: EOFfailure. I’ll add one shared HTTP-semantics helper ininternal/outputand use it before decompression in normalized, raw, and streaming body paths. For HEAD and bodyless status codes, headers/status remain available while the body is represented as empty and still closed correctly. - Assistant
The line-based insertion landed inside the
Responsecomposite literal because the displayed line numbers shifted from the earlier excerpt;gofmtcorrectly caught it, and the CLI replacements were not applied. I’ll restore only the malformed output file, then use exact text replacements anchored on the existingdecodeBodydeclaration and direct line edits for the two CLI functions. - Assistant
The helper is now structurally correct, but the old
decodeBodydoc comment sits above it and should remain attached to its intended function. I’ll reorder that comment and apply the CLI guards using the exact text just displayed. - Assistant
The specialized
replacecommand still refuses the CLI match despite locating it, so I’ll use the editor’s explicit line ranges now that the exact locations are known. The first edit changes only the guard; the second inserts the bodyless-response wrapper afteroriginal := resp.Body. - Assistant
The second explicit range included the original decompressor initialization line, leaving
readeranderrundefined. I caught this in the displayed result before testing; I’ll restore that initialization immediately after the bodyless guard, then compile and run focused tests. - Assistant
Focused output and CLI suites pass. I’ll now rerun the original 204 reproducer and include two edge checks: a HEAD response and a 304 should also ignore misleading gzip headers, while a normal 200 with empty gzip data must still fail so genuine malformed encoded responses are not silently accepted.
- Assistant
The fixed reproducer behaves correctly: bodyless responses normalize successfully, while an invalid empty gzip body on a normal 200 still errors. A test-created lock artifact appeared and is not part of the fix, so I’ll remove it and run the full non-integration suite as prescribed by the repository.
- Assistant
The complete standard suite passes. Since this changes CLI response handling, project guidance also requests integration-tagged tests; I’ll run those, then inspect the final diff and repository status for accidental artifacts.
- Assistant
Integration tests also pass. I’ll now perform a final review: remove any regenerated lock artifact, inspect the exact patch, verify formatting/vetting, and ensure only the two intended source files remain modified.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.