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 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
Let me analyze the issue. The problem is that
restishfails when receiving an HTTP 204 (No Content) response with an empty body. The error occurs because it's trying to parse/decompress the response body but encounters an EOF error.Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me look at the error trace in the issue description. The stack trace shows:
cli/request.go:568-MakeRequestAndFormatcli/operation.go:142-Operation.command.func1
Let me look at the cli directory structure.
Assistant
The issue description mentions
cli/request.goandcli/operation.go. Let me search more broadly:Assistant
The file structure seems different from the stack trace. Let me look at the main restish file and search for where the response is parsed:
Assistant
Now let me look at the internal/cli directory:
Assistant
The error trace points to response parsing, specifically with gzip decoding and EOF. Let me look at the http.go file where the request/response handling happens:
Assistant
Let me search for the error message differently:
Assistant
Let me look at the
http.gofile which likely handles the request/response logic:Assistant
The issue is likely around line 667 or 689 where it tries to decompress the response body. Let me look at the
Decompressfunction and how it handles empty bodies:Assistant
Let me look at the http.go file around lines 660-700 where the Decompress is called:
Assistant
Now let me look at where the body is parsed after decompression. Let me search for the error message more broadly:
Assistant
Let me look for where the panic/recovery is handled and look for the main request processing:
Assistant
The issue seems to be from an older version of the code. Let me search for where response body reading happens and look for the content parsing:
Assistant
The issue is about HTTP 204 responses with Content-Encoding: gzip but an empty body. When the server returns gzip encoding but an empty body, the gzip decompressor fails with EOF. Let me look at the
decompressedResponseBodyfunction and see where it's called from, and also check for the 204 handling:Assistant
Let me look at the broader context where the response is handled. Let me look for where the response body is actually decoded/parsed:
Assistant
Let me look at the
normalizeHTTPResponsefunction since that seems to be where the response body is processed:Assistant
The key function is
output.Normalize. Let me look at that:Assistant
Now I can see the issue! In
decodeBody, the function callsreg.Decompress(encoding, resp.Body)on line 87. When the server returns a204 No ContentwithContent-Encoding: gzipbut an empty body, the gzip decompressor tries to read from an empty reader and fails with EOF.Let me look at the Decompress function in the content registry:
Assistant
Now let me look at the
defaultGzipDecompressfunction:Assistant
Now I understand the issue. The problem is in
decodeBodyinresponse.go. When the server returns a204 No Contentresponse withContent-Encoding: gzipbut an empty body, the gzip reader is created successfully, but whenio.ReadAllis called on the gzip reader, it fails because there's nothing to read (EOF from the gzip header reading).The fix should check if the response body is empty (or has a 204 status code) before attempting to decompress. Let me also check how the response body looks for 204:
Looking at the log from the issue:
DEBUG: Got response from server in 426.428041ms: HTTP/2.0 204 No Content Content-Encoding: gzipThe response has a
Content-Encoding: gzipheader but no body. Whengzip.NewReaderis called and then data is read, it will fail because there's no gzip data.The fix should be in
decodeBody- it should handle the case where the body is empty before trying to decompress. Let me check if there's a way to detect an empty body:Assistant
Now I understand the issue clearly. When the server returns a 204 with
Content-Encoding: gzip, the code:- Gets the Content-Encoding header value "gzip"
- Creates a gzip reader wrapping the empty body
- Tries to read from the gzip reader
- The gzip reader fails because it expects gzip header data but finds EOF
The fix should be to skip decompression when the response has no body content (e.g., HTTP status 204, 304, or when Content-Length is 0). Let me also check for other status codes that shouldn't have bodies:
Assistant
The best fix would be to handle this case in
decodeBody. For responses that are expected to have no body (204, 304, 1xx), we should skip decompression and return an empty body. Also, for cases where the body is empty (like an empty reader), we should handle the decompression gracefully.Let me also check what happens when there's a
Content-Length: 0header:Assistant
Let me check the tests to understand the expected behavior:
Assistant
Let me look at how the existing tests handle 204 responses:
Assistant
Good, there's a test for empty body 204 responses. Let me look at
makeResp:Assistant
Let me continue with the proper tool call format.
Assistant
Now I understand the issue. The
decodeBodyfunction tries to decompress an empty body when the server sends aContent-Encoding: gzipheader with a 204 response. The fix should skip decompression for responses that are not expected to have a body (status codes 1xx, 204, 304).Let me look at the current
decodeBodyfunction and implement the fix:Assistant
Now let me look at the full
decodeBodyfunction:Assistant
The issue is clear now. The
decodeBodyfunction attempts to decompress the body using theContent-Encodingheader. When the response hasContent-Encoding: gzipbut an empty body (like HTTP 204), the gzip reader returns an EOF error when trying to read.The fix should skip decompression for responses that should not have a body. According to HTTP specs:
- 1xx (Informational) responses must not have a body
- 204 (No Content) must not have a body
- 304 (Not Modified) must not have a body
Let me first create a test script to reproduce the issue, then implement the fix.
Assistant
The environment doesn't have HOME set properly. Let me try setting HOME as well.
Assistant
Good, the basic test passes but it doesn't have the
Content-Encoding: gzipheader. Let me create a test to reproduce the issue with the gzip header:Assistant
I need to run the reproduce script to confirm the issue.
Assistant
Internal packages can't be imported from outside the module. Let me create the test script inside the repository.
Assistant
The function names are different. Let me check the actual content registry API.
Assistant
I see. The function is
content.New()notcontent.NewRegistry(). Let me also check how tests register the defaults.Assistant
Now I understand. Let me update my test file to use the correct API.
Assistant
I need to run the test to reproduce the issue.
Assistant
I've successfully reproduced the issue. The error is
decompressing response: EOF. Now I need to fix this in thedecodeBodyfunction. The fix should skip decompression for responses that are not expected to have a body (HTTP status codes 1xx, 204, 304).Let me look at the
decodeBodyfunction again and implement the fix:Assistant
Now I need to implement the fix. The fix should check if the response status code indicates no body (1xx, 204, 304) and skip decompression in those cases.
Assistant
Wait, I don't have the
edittool - I need to use theeditcommand format properly. Let me use the edit command to modify the file.Assistant
I need to use the
opencommand with the correct syntax from the system prompt. Let me check the usage format.Assistant
I'll add the check for status codes that must not have a body at the beginning of the
decodeBodyfunction.Assistant
I see the issue - my edit removed the line that gets the encoding. Let me fix that:
Assistant
Let me verify the fix by running the test I created earlier to reproduce the issue.
Assistant
The test passes now. Let me also run the existing tests in the output package to make sure I haven't broken anything.
Assistant
All output tests pass. Now let me add more comprehensive tests for edge cases and also run the broader test suite.
Assistant
I need to run the tests I just added to verify they pass with the fix.
Assistant
The test files are in the root directory but the package name is
restish_test. Let me run them properly.Assistant
All my new tests pass. Now let me clean up my test file since I shouldn't leave test files in the repository, and run the broader test suite to make sure nothing is broken.
Assistant
Let me run the existing tests in the output package to make sure I haven't broken anything.
Assistant
All tests pass. Let me now also run the broader tests in the internal/cli package to make sure my change doesn't break any higher-level functionality.
Assistant
The test output was cut off. Let me wait for it to complete and check if all tests pass. Let me run a shorter test to verify things are working.
Assistant
All CLI tests pass. Now let me verify my fix by reviewing the final change:
Assistant
Now let me run a broader set of tests to make sure the fix doesn't break anything.
Assistant
All tests pass. Let me verify the fix one more time by viewing the final modified file:
Assistant
Now let me submit my changes.
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
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →