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
Let's look around lines 250-380 to understand where the decode happens, likely using content unmarshal.
Assistant
Now let's find
output.Normalize:Assistant
Now add the
bytesimport.Assistant
There's a duplicate
)on line 14. Let me fix that.Assistant
Now let's build.
Assistant
Build succeeds. Now let's run existing tests for output package and content package.
Assistant
Now let's write a reproduce test simulating the actual issue: 204 response with gzip Content-Encoding but empty body.
Assistant
The fix works — no more EOF error for gzip-encoded empty (204) body. Let's clean up the temp test dir.
Assistant
Now let's also verify with a non-empty gzip body to ensure decompression still works correctly (edge case: the peek byte must be correctly prepended).
Assistant
Ah, need
content.Default()instead ofcontent.New(). Let's fix the repro.Assistant
Both cases work correctly: normal gzip decompression works fine (peek+MultiReader correctly reconstructs the stream), and empty body (no encoding) still works. Let's clean up temp dir.
Assistant
Now let's run the full test suite to make sure nothing else broke.
Assistant
All tests pass. Now let's also add a targeted test scenario like the real HTTP flow through
internal/clito be extra sure end-to-end. Let's check if there's a test file that constructs 204 responses already, and consider testing brotli/deflate too for empty body.Assistant
These already cover 204 without gzip. Since existing tests pass and the fix specifically targets the gzip-with-empty-body edge case (not previously tested), that's fine. Let's view final diff.
Assistant
The diff is clean and minimal. Now let's go through the checklist.
Assistant
Now let's update
Decompressto peek for empty reader and handle it gracefully, then simplifydecodeBodyin response.go back to its original simpler form (relying on the registry fix), and also fixrawResponseBodyBytes/decompressedResponseBodyimplicitly since they all callDecompress.Assistant
Extra closing brace at line 332. Let's remove it.
Assistant
Now add "bytes" import.
Assistant
Duplicate
"compress/flate". Remove line 10.Assistant
Now let's simplify
output/response.godecodeBody to remove the now-redundant peek logic since Registry.Decompress handles it.Assistant
Now remove the unused
bytesimport from response.go since we reverted that part.Assistant
This file is back to its original form. Now the fix is entirely in
content/registry.go. Let's build and test.Assistant
All tests pass. Now let's re-verify the reproduce scenario at the registry level and full CLI flow level.
Assistant
All cases work correctly. Let's clean up the temp directory and run full test suite once more, then check git diff.
Assistant
All good. Let's view the final diff.
Assistant
That file is unrelated to our change (pre-existing). Our modified file is properly formatted. Let's do a final full test run to be safe.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.