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
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /restish, current file: none) bash-$
- Assistant
I’ll trace the response decoding and formatting path around the reported panic, inspect existing tests for empty responses and content encodings, then reproduce the failure before making a focused fix.
- Assistant
The stack trace references an older repository layout; the current checkout differs, so I’ll locate the corresponding source files and module structure first.
- Assistant
This version appears to be a plugin-oriented refactor rather than the historical
clitree. I’ll inspect the module, entry point, branches/history, and all Go packages to identify where HTTP responses are now decoded. - Assistant
The relevant implementation is now under
internal/cliandinternal/content. I’ll inspect body reading/decompression, response normalization, and tests that exercise 204 or zero-length bodies. - Assistant
There are two response paths: the general normalized-output decoder and CLI fetch/stream handling. I’ll read those exact functions and their current 204 tests to determine whether the historical bug remains in a specific content-encoding branch.
- Assistant
The failure is reproducible by inspection:
gzip.NewReaderreturnsio.EOFbefore the existing zero-length check because decompression is initialized first. HTTP semantics prohibit response content for HEAD, 1xx, 204, and 304 responses, so those should bypass content decoding regardless of strayContent-Encoding. I’ll confirm which execution modes call each decoder and construct a minimal temporary reproduction againstoutput.Normalize. - Assistant
The temporary reproduction is blocked by this environment’s unset Go module cache, but it reaches the exact standard-library behavior described (
gzip.NewReaderon an empty reader returns EOF). The CLI also has raw and streaming paths that initialize decompression independently, so I’ll inspect routing and apply one shared HTTP “response may have body” rule consistently rather than fixing only formatted output. - Assistant
A status-aware bypass in
output.Normalizefixes normal formatting, but raw/stream output can still fail before normalization. The cleanest general fix is at decompression: treat an actually empty encoded stream as an empty body, while preserving errors for non-empty malformed gzip data. This also handles legal zero-length bodies on any status and all call paths. I’ll inspect encoding registrations to ensure a registry-level empty check won’t interfere with custom codecs or reader closure. - Assistant
I’ll update
Registry.Decompressonly after a supported encoding is found: buffer and peek one byte, return an empty reader on EOF, otherwise pass the buffered reader to the codec. This preserves unsupported-encoding errors, preserves malformed non-empty payload errors, works for built-in and custom codecs, and fixes formatted, raw, and streaming response paths without status-specific duplication. - Assistant
The focused change is in place. I’ll now run the content and output package tests with an explicit temporary Go cache (the environment has no default GOPATH), then run the CLI tests most likely to cover all response modes.
- Assistant
The affected package tests pass; the initial command’s only failure was an intentionally nonexistent placeholder path, while the actual content, output, and selected CLI tests all succeeded. I’ll now rerun the exact temporary 204+gzip reproduction and include a non-empty malformed gzip case to verify the fix does not hide real corruption.
- Assistant
The exact reproduction now returns status 204 with a nil body and no error, while a non-empty invalid gzip stream still returns
unexpected EOF. I’ll run the full repository Go test suite and static checks available throughgo test, then review the final diff and repository cleanliness. - Assistant
The full suite passes. One test created an untracked runtime lock file, which is not part of the fix; I’ll remove it and perform a final status/diff check 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.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →