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 repository structure and finding the relevant code that handles HTTP response parsing, particularly around the error reported in the issue.
The error is:
ERROR: Parse response errorERROR: Caught error: EOF
This happens when the server returns a 204 No Content response with an empty body. The code panics at
cli/request.go:568.Let me explore the repository structure first.
Assistant
Let me look at the relevant files. The error trace points to
cli/request.go:568andcli/operation.go:142. But the actual directory structure showscmdandinternal- let me check.Assistant
No results. Let me search more broadly.
Assistant
Let me check the module structure and find the actual request handling code
Assistant
Let me search for the actual request handling code. The module path has changed but the structure should be similar
Assistant
The grep might have failed due to some issue. Let me try more carefully.
Assistant
No results for "MakeRequestAndFormat". Let me explore the codebase structure more.
Assistant
Let me look at the key files. The stack trace mentioned
cli/request.goandcli/operation.go, which in this repo might beinternal/cli/request_exec.goandinternal/spec/operation.goAssistant
Now let me look at the response normalization code which is likely where the parsing error occurs
Assistant
Now I can see the issue. The 204 response has
Content-Encoding: gzipbut no body. Whenreg.Decompressis called on an empty gzip stream, it returns an EOF error. Let me look at the decompress logicAssistant
Now I understand the issue. When a 204 No Content response has
Content-Encoding: gzip, thedecodeBodyfunction tries to decompress an empty stream, which causes an EOF error. Let me look at how this is called and handledAssistant
Let me find where the "Parse response error" error message originates
Assistant
Let me search more broadly
Assistant
The error messages might be from an older version. Let me search for "EOF" handling and look at the dispatch flow
Assistant
Let me look at the HTTP handler in cli where response errors are handled
Assistant
Let me look at the dispatch.go which might have the error handling for response parsing
Assistant
Let me look at the specific part of
http.gowherenormalizeHTTPResponseisAssistant
Let me look at the context around line 368 in http.go
Assistant
Now let me find the
responseBodyReadErrorfunctionAssistant
Let me look at line 1452.
Assistant
Now I have a clear picture of the bug. Let me look at
decodeBodyonce more and plan the fix.The issue is:
- A 204 No Content response comes back with
Content-Encoding: gzipbut an empty body decodeBodytries to decompress with gzip before checking if there's any body contentgzip.NewReaderon an empty stream returnsio.EOF- This error propagates up as "decompressing response: EOF" which is confusing
The fix should be in
decodeBodyto handle responses with no body (status 204, 304, or Content-Length: 0) before attempting decomp- A 204 No Content response comes back with
Assistant
Now I understand the full picture. Let me create a reproducible test first, then fix it.
Let me first check if there are existing tests for
decodeBodyorNormalizeAssistant
Let me look at the existing tests for Normalize in output_test
Assistant
Now let me create a quick script to reproduce the issue
Assistant
Let me fix the filename
Assistant
Let me check the Go environment
Assistant
Let me set up the go environment
Assistant
Let me write a test inside the repository instead
Assistant
Let me set all required Go environment
Assistant
Now I understand the issue fully. Let me fix the
decodeBodyfunction ininternal/output/response.go. The fix should skip decompression and body reading when the response status indicates no body (204, 304) or Content-Length isAssistant
Let me use the correct open syntax.
Assistant
Now I'll fix the
decodeBodyfunction. The issue is that when a response has no body (e.g., 204 No Content) but hasContent-Encoding: gzip, the gzip decompressor fails on the empty stream. I need to add an early return for responses that have no body.Assistant
Let me use the proper edit syntax with
Assistant
Good. Now let me verify it compiles and run
Assistant
Compiles. Now let me run the existing tests
Assistant
The
ContentLength == 0check is too aggressive - it catches manually constructed test responses that don't set ContentLength. The Go HTTP client setsContentLengthto -1 for unknown lengths, but when creating a Response struct manually, it defaults to 0. Let me fix this by removing the ContentLength check and relying only on status codes.Assistant
Now let me run the tests
Assistant
Let me run the full test suite for the output package
Assistant
All tests pass. Let me also run the CLI tests that relate to response handling
Assistant
Let me verify my fix handles the specific scenario. Let me look at what
http.NoBodyis and confirm the fix works for the 204 + gzip caseAssistant
Let me create the test within the repo
Assistant
The 204 and 304 cases pass correctly. The third case (200 with gzip content) has a type assertion issue in my test, not a code problem. Let me clean up and fix the test
Assistant
Let me fix the import
Assistant
The fix works. Let me clean up the temporary
Assistant
Now let me run a broader set of tests to make sure nothing is broken
Assistant
All tests pass. Let me verify the final state of the fix and review the change
Assistant
The fix is clean and minimal. Let me verify the full file looks correct.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.