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.code$ 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:codeERROR: Parse response error ERROR: Caught error: EOFHere is the full log:
code Assistant
Let me start by understanding the issue:
- When an API returns HTTP 204 (No Content), restish fails with "Parse response error" and "Caught error: EOF"
- The error occurs in
cli/request.go:568in theMakeRequestAndFormatfunction - HTTP 204 means "No Content" - there's no body to parse, so the code should handle this gracefully
Let me explore the repository structure and understand the codebase.
Assistant
Let me look at the relevant files mentioned in the stack trace.
Assistant
Let me find the correct file path.
Assistant
The stack trace mentions
github.com/danielgtaylor/restish/cli/request.go:568. Let me look at the structure of the project more closely.Assistant
Let me find the cli directory. It seems like the code is in
internalor elsewhere. The stack trace showsgithub.com/danielgtaylor/restish/cli/request.go, but maybe the module structure is different. Let me check the go.mod.Assistant
Let me search for
MakeRequestAndFormatin the codebase.Assistant
Let me search more broadly for related functions.
Assistant
Let me look at the structure more carefully. Maybe the code is structured differently in this version.
Assistant
Let me look at
internal/cli/http.gowhich seems relevant, and also search for the response handling.Assistant
Let me look at the relevant files. The main HTTP handling seems to be in
internal/cli/http.go.Assistant
Let me look at the relevant sections of
http.go- particularly around the response handling and body reading.Assistant
Let me just use bash to read the file.
Assistant
Let me search for the actual response parsing logic. Let me search for where the response body is read and decoded
Assistant
Let me look at lines around 660-690 where the body is decompressed and read, and also around the output formatting
Assistant
Let me search more specifically for "Parse response" and "Caught error" in the codebase.
Assistant
Let me look at the output processing and response parsing flow in the code
Assistant
Let me look at
responseMetadataOnlyat line 743 andformatResponseat line 467:Assistant
Let me look at
responseMetadataOnlywhich creates the output.Response from http.Response:Assistant
Let me look at
formatResponseBodyWithPrintat line 893Assistant
Let me find where the response body is decoded/parsed (where raw bytes become resp.Body):
Assistant
Let me look at where output.Response is built from http.Response, including body parsing:
Assistant
Let me look at the output package for response parsing:
Assistant
Let me look at
response.gofor the Response type definition:Assistant
Now I can see the issue. When a 204 response has no body but still has
Content-Encoding: gzipheader, theDecompressfunction might fail trying to decompress an empty stream. Let me check the decompression logic:Assistant
Let me look at the content registry for the Decompress function.
Assistant
Let me find where
Normalizeis called to understand the full response processingAssistant
Let me look at
request_exec.gowhereoutput.Normalizeis calledAssistant
Let me look at the test files to understand expected behavior for 204:
Assistant
Let me see how
makeRespconstructs the responseAssistant
Let me create a reproduction script to verify the issue
Assistant
The file name ends with _test.go. Let me rename it.
Assistant
Let me set up the Go
Assistant
Let me run the existing tests for the output package to see if they pass:
Assistant
Let me fix the Go environment.
Assistant
Let me write a test within the output package to verify the issue:
Assistant
Let me fix the test file
Assistant
I've confirmed the bug. When a 204 response has
Content-Encoding: gzipbut an empty body, the gzip decompressor fails with "EOF" because there's no gzip header to read.Let me clean up the test file and implement the fix:
Assistant
Now let me look at the
decodeBodyfunction more closely and implement the fix:Assistant
Let me view the decodeBody function:
Assistant
Now I understand the issue. Let me implement the fix. The
decodeBodyfunction should check for empty response bodies before attempting decompression:Assistant
Let me use the
replacecommand to make the editAssistant
Good, the change looks correct. Now let me run the existing tests to make sure nothing is broken:
Assistant
Let me see which test failed
Assistant
Let me see the FAIL lines specifically.
Assistant
Let me see the details of the failing tests:
Assistant
Assistant
Let me implement a better fix. The approach: read the raw body bytes first, check if empty, then decompress and decode:
Assistant
Now let me check the imports at the top of the file
Assistant
I need to add
bytesto the imports. Let me add itAssistant
Let me navigate to the top of the file and edit
Assistant
Now let me add
bytesto the importsAssistant
Good. Now let me run the tests again to verify the fix:
Assistant
All output tests pass. Now let me run the broader test suites to make sure nothing else is broken:
Assistant
All CLI tests pass. Let me run the remaining test suites to be thorough:
Assistant
All tests pass. Let me now verify the fix resolves the issue by creating a quick in-package test:
Assistant
The fix works. Let me clean up the temporary test file:
Assistant
Let me verify the final state of the changed file:
Assistant
Let me see the full diff of all changes:
Assistant
Let me run all tests one final time to make sure everything passes:
Assistant
All tests pass. Let me go through the checklist:
-
✅ If an error was reported in the issue description, I have successfully reproduced it. I created a test case that reproduces the exact scenario: a 204 No Content response with
Content-Encoding: gzipheader and empty body, which fails with "decompressing response: EOF". -
✅ If an error was reported in the issue description, I have confirmed that my fix resolves the error. After the fix, the same test case passes - the empty body is detected before decompression, and nil is returned cleanly.
-
✅ I have thought about edge cases and made sure my fix handles them as well.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.