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
The issue is about restish failing when handling HTTP 204 (No Content) responses. The error message shows "EOF" when trying to parse the response, which happens because the response body is empty.
Let me first explore the repository structure to understand how responses are parsed and where the issue might be.
Assistant
Let me explore the structure further. The error mentions
cli/request.go:568andcli/operation.go:142. Let me look at the cli directory.<tool_call> <function=bash_terminal> <parameter=command> ls -la cli/ </tool_call>
Assistant
Let me list the cli directory to see its contents.
Assistant
The cli directory doesn't exist in the current path. Let me check the structure better. It seems like the cli directory might be in the cmd directory or elsewhere. Let me explore the internal directory.
<tool_call> <function=bash_terminal> <parameter=command> find . -name "request.go" -o -name "operation.go" | head -20 </tool_call>
Assistant
I need to search for request.go and operation.go files to find where the error handling occurs.
Assistant
I found two files. Let me also check the cmd directory structure since that's where the CLI code might be.
<tool_call> <function=bash_terminal> <parameter=command> ls -la cmd/ </tool_call>
Assistant
The command didn't run. Let me try again to list the cmd directory.
Assistant
Looking at the structure, the main restish CLI code is probably in the cmd/restish directory. Let me explore that and also look at the internal directory.
<tool_call> <function=bash_terminal> <parameter=command> ls -la cmd/restish/ </tool_call>
Assistant
The command didn't run properly - I need to look at the response format. It seems like the tool is waiting for a response. Let me try a simple command first to see if the terminal is working.
Assistant
The command worked this time. Now let me look at the cmd/restish directory and the internal directory to find the CLI code that handles responses.
<tool_call> <function=bash_terminal> <parameter=command> ls -la internal/ </tool_call>
Assistant
The command didn't execute properly - I need to include proper tool call format with arguments. Let me try again with the correct format.
Assistant
There's a cli directory in internal/. This is where the CLI code is likely located. Let me explore it.
Assistant
Now let me look at the request_exec.go file since the error traceback mentioned request.go:568 and operation.go:142. The request_exec.go file likely contains the request execution code.
<tool_call> <function=bash_terminal> <parameter=command> head -100 internal/cli/request_exec.go </tool_call>
Assistant
I need to properly format the bash command to read the file. Let me try again with a proper command.
Assistant
Now let me look at the output package where the response normalization happens:
Assistant
Let me look at the response.go file to understand how responses are normalized:
Assistant
Now I can see the issue! The
decodeBodyfunction reads the body withio.ReadAll. When the body is empty (as in HTTP 204 responses), it returnsnil, nil, nil, which is fine. However, let me also check the content package to see how the Decode function works, since the issue is happening at decode time.Let me check the content package:
<tool_call> <function=bash_terminal> <parameter=command> ls internal/content/ </tool_call>
Assistant
I need to continue exploring the content directory structure to understand how decoding works.
Assistant
Let me look at the registry.go file to understand how content decoding works:
<tool_call> <function=bash_terminal> <parameter=command> cat internal/content/registry.go </tool_call>
Assistant
Let me try the command again to see the registry.go file.
Assistant
Now let me look at the defaults.go file to understand how the registry is set up:
Assistant
Now let me look at where the error actually happens. The stack trace mentioned
cli/operation.go:142. Let me find that file and see how it handles responses:<tool_call> <function=bash_terminal> <parameter=command> cat internal/cli/operation.go </tool_call>
Assistant
The command didn't execute - I need to properly format the bash command. Let me try again.
Assistant
The operation.go file is not in the internal/cli directory. Let me search for it again.
Assistant
Let me look at the cli.go file since the stack trace mentions cli.go:849:
Assistant
Now I need to look at the operation_auth.go file to understand how operation responses are handled. Let me check the spec/operation.go file which was found earlier.
<tool_call> <function=bash_terminal> <parameter=command> cat internal/spec/operation.go </tool_call>
Assistant
The command didn't run properly. Let me continue to explore and find where the issue is occurring. Based on the error trace, the issue is in the response parsing. Let me look at the internal/cli directory more carefully to find where the error originates.
Assistant
The error message "Parse response error" is not found, so the error is likely coming from a panic with "EOF". Let me search for the panic pattern:
Assistant
Let me look at the http.go file which handles HTTP requests and responses:
Assistant
Let me look at the operation_auth.go file to see how operations handle responses:
<tool_call> <function=bash_terminal> <parameter=command> cat internal/cli/operation_auth.go </tool_call>
Assistant
The tool seems to be having issues executing commands. Let me try to read a specific file using a different approach.
Assistant
The files are large. Let me look at the key file - request_exec.go - more carefully to understand how responses are handled. The error seems to be in the output normalization or formatting phase. Let me search for where the "EOF" error might be coming from:
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "decodeBody|Normalize|io.ReadAll" internal/output/response.go </tool_call>
Assistant
Let me look at the defaults.go file to see how the compress/flate/brotli/encoding are handled:
Assistant
Now I see how the encoding works. The issue is that when a 204 response with gzip Content-Encoding is received, the gzip decompression is attempted, but since the body is empty, the gzip reader may return EOF. Let me look at the gzip decompression function:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 10 "defaultGzipDecompress" internal/content/registry.go </tool_call>
Assistant
Let me look at the gzip decompress function in registry.go:
Assistant
Now I understand the issue. Looking at the code in
internal/output/response.go, thedecodeBodyfunction reads the response body withio.ReadAllafter decompression. When a response has status 204 (No Content) and the server sendsContent-Encoding: gzipwith an empty body, the gzip reader fails when trying to read from an empty stream.Let me first create a test to reproduce the issue:
Assistant
Let me set up the environment first:
Assistant
I've reproduced the issue! When the server sends a 204 response with
Content-Encoding: gzipbut an empty body,gzip.NewReader()fails with an EOF error.Now let me look at the code flow more carefully to understand where the fix should go:
Assistant
Now I understand the issue. The problem is in the
decodeBodyfunction ininternal/output/response.go. When a response hasContent-Encoding: gzipbut an empty body (which happens with HTTP 204 responses), thegzip.NewReader()call fails with an EOF error.The fix should handle the case where the response status code indicates no body should be present (like 204 No Content, 205 Reset Content, 304 Not Modification), or when the body is genuinely empty. Let me fix the
reg.Decompressfunction to handle empty bodies properly:Assistant
Assistant
Now let me apply the fix to the actual file:
Assistant
Let me use the edit command to apply the fix directly to the file:
Assistant
Assistant
The command didn't run - let me try running the python script directly.
Assistant
Let me use the edit command to apply the fix directly to the file.
Assistant
Let me verify the fix was applied correctly:
Assistant
The
isResponseNoBodyfunction was not added correctly. Let me check what happened and add it properly:<tool_call> <function=bash_terminal> <parameter=command> grep -n "isResponseNoBody" internal/output/response.go </tool_call>
Assistant
Let me search for the isResponseNoBody function to see if it was added:
Assistant
The function is being called, but I need to verify the function itself is defined. Let me check the lines around line 83:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '60,100p' internal/output/response.go </tool_call>
Assistant
The command didn't execute properly. Let me try with the correct format.
Assistant
The
isResponseNoBodyfunction call was added, but the function definition is missing. Let me add it after theresponseURLfunction:Assistant
I need to add the
isResponseNoBodyfunction after theresponseURLfunction. Let me do that using the edit command.Assistant
Let me verify the fix was applied correctly:
Assistant
The function was added in the wrong place. Let me restore the file and apply the fix correctly:
Assistant
Now let me apply the fix correctly by reading the file and replacing the content properly:
Assistant
Let me verify the fix was applied correctly:
Assistant
The function was inserted in the wrong place again - it got inserted inside the
responseURLfunction. Let me restore the file and try a different approach:<tool_call> <function=bash_terminal> <parameter=command> git checkout internal/output/response.go </tool_call>
Assistant
The command didn't run. Let me try again with proper formatting.
Assistant
Let me try a more careful approach to apply the fix. I'll use the sed command to insert the function at the correct location:
<tool_call> <function=bash_terminal> <parameter=command> cat internal/output/response.go </tool_call>
Assistant
Let me try to understand the issue - the bash terminal commands seem to work fine. Let me check the file content and then apply the fix.
Assistant
The file has 169 lines. Let me look at the full file content first:
<tool_call> <function=bash_terminal> <parameter=command> cat -n internal/output/response.go | head -90 </tool_call>
Assistant
The tool is not executing commands properly. Let me check if there's a specific formatting requirement or issue. The commands seem to be working but the output is being truncated or there's a formatting issue. Let me try a different approach - using the bash_terminal function directly with simpler commands first.
Assistant
Now I have the original file. Let me create a Python script file and run it:
Assistant
The fix was applied. Let me verify the changes:
Assistant
The function was inserted incorrectly again. Let me restore and use a more precise approach:
Assistant
The file was restored. Now let me try a more careful approach to make the fix. I'll look at the exact line numbers and use the edit command to add the function properly.
Assistant
The
responseURLfunction is at line 71 anddecodeBodyis at line 81. Let me check the content around line 77 (where responseURL function ends):<tool_call> <function=bash_terminal> <parameter=command> sed -n '70,82p' internal/output/response.go </tool_call>
Assistant
The bash_terminal command is not executing properly. Let me try a simpler approach - create the entire fixed file content and write it directly.
Assistant
Good, now I can see the file content. Let me look at the rest of the file:
<tool_call> <function=bash_terminal> <parameter=command> tail -70 internal/output/response.go </tool_call>
Assistant
The commands seem to be working but with some delays. Let me try again.
Assistant
The fix is already applied and looks correct. Let me now verify the code compiles and run the tests to make sure everything works.
First, let me check the full file to ensure the fix is correct:
<tool_call> <function=bash_terminal> <parameter=command> cat internal/output/response.go </tool_call>
Assistant
The tool calls are working but sometimes there's a delay or formatting issue. Let me try to verify the file content more carefully.
Let me look at the file to make sure the fix is properly applied:
Assistant
The command exited with code 1, which means grep didn't find any matches. This indicates that the fix was not properly applied. Let me check the git status to see what changes have been made.
Assistant
Let me properly apply the fix now. First, let me create a Python script that correctly modifies the file:
Assistant
Now let me verify the fix was applied correctly:
Assistant
The fix has been applied. Now let me verify the function is correctly defined and check if the code compiles:
Assistant
The fix looks correct. Now let me verify the code compiles by running
go build:Assistant
The code compiles successfully. Now let me run the existing tests to make sure the fix doesn't break anything:
Assistant
All tests pass. Now let me also run the tests for the content package to make sure the decompression logic still works correctly:
Assistant
The tests pass. Now let me also run the tests for the cli package to ensure the integration is working:
Assistant
All tests pass. Now let me create a test script to verify that the fix works for the specific issue described - handling HTTP 204 responses with gzip Content-Encoding:
Assistant
Assistant
The command didn't run. Let me try again with proper formatting.
Assistant
Now let me run the tests to verify the fix:
<tool_call> <function=bash_terminal> <parameter=command> go test -v ./internal/output/ -run "TestNormalizeHTTP" </tool_call>
Assistant
Let me try running the tests properly by formatting the command correctly.
Assistant
The tests pass! All the tests for HTTP 204, 205, 304, 1xx with gzip encoding pass, as well as the test for HTTP 200 with gzip encoding to ensure we didn't break normal functionality.
Now let me run all the tests in the repository to make sure everything is working correctly:
<tool_call> <function=bash_terminal> <parameter=command> go test ./... </tool_call>
Assistant
Let me run the tests with proper formatting.
Assistant
All tests pass! Let me also verify that the fix is correct by looking at the git diff:
<tool_call> <function=bash_terminal> <parameter=command> git diff internal/output/response.go </tool_call>
Assistant
Let me view the git diff to see what changes have been made to the response.go file.
Assistant
The diff shows the fix I applied. Now let me also check the test file I added:
<tool_call> <function=bash_terminal> <parameter=command> git status </tool_call>
Assistant
The command didn't run. Let me try again with proper formatting.
Assistant
The fix is complete and all tests pass. Let me summarize the solution:
Summary
The issue was that restish failed with an EOF error when handling HTTP 204 (No Content) responses that had a
Content-Encoding: gzipheader but an empty body. The problem occurred in thedecodeBody()function ininternal/output/response.gobecause:- When the server sends a 204 response with
Content-Encoding: gzip, thegzip.NewReader()call fails with EOF because there's no valid gzip header to read from an empty body. - The
decompress()function attempted to decompress even though the response should have no body.
Fix Applied
-
Added
isResponseNoBody()function - This helper function checks if the HTTP status code indicates no body content per HTTP semantics:- 204 No Content
- 205 Reset Content
- When the server sends a 204 response with
Assistant
The fix is complete. The changes I made address the issue where restish fails on HTTP 204 (No Content) responses with gzip Content-Encoding.
The solution:
- Added
isResponseNoBody()function that checks if the status code indicates no body (204, 205, 304, 1xx) - Modified
decodeBody()to check for no-body responses before attempting decompression
This is a minimal, focused fix that:
- Resolves the reported issue with HTTP 204 and gzip encoding
- Handles other no-body status codes (205, 304, 1xx)
- Preserves existing functionality for normal responses
- All existing tests pass
- New tests verify the fix
Let me submit the fix. </tool_call>
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.