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
I'll start by exploring the repository structure and understanding the codebase, then look at the specific file mentioned in the issue.
Assistant
I'll start by exploring the repository structure.
Assistant
The structure has been refactored. Let me look at the relevant files.
Assistant
The error message in the issue is from an older version. Let me look at the http.go file and the request handling logic more carefully.
Assistant
Let me look at the
formatResponsefunction and the body handling code in detail.Assistant
Now let me look at the
output.Normalizefunction which is the actual decoder.Assistant
The
decodeBodyalready handleslen(raw) == 0. But the issue is about a gzip-encoded empty body. Let me look at theDecompressfunction in the content registry.Assistant
Now I understand the issue. The
gzip.NewReader(r)returnsio.EOFwhen the input is empty (no gzip header to read). Let me write a reproduction script to confirm this.Assistant
Now let me write a reproduction script to confirm the issue with an empty gzip body.
Assistant
Let me write a proper reproduction test using the external test package.
Assistant
I've reproduced the issue.
gzip.NewReaderreturnsio.EOFwhen the input is empty. Let me also confirm the full flow throughNormalize.Assistant
I've confirmed the full flow fails with "decompressing response: EOF". Let me check the brotli and deflate cases with empty input too, and examine the broader context.
Assistant
All three decompressors fail with empty input. Let me check existing tests around normalize and 204 responses, and look at the git history to understand how this was handled before.
Assistant
Now I understand the bug fully. The
Decompressfunction fails when the body is empty butContent-Encodingis set (e.g., gzip on a 204 response). This affects multiple callers:decodeBody,rawResponseBodyBytes, anddecompressedResponseBody. Let me check the imports in registry.go and implement a fix at the centralDecompresslevel.Assistant
bufio,io, andstringsare all already imported. Now let me implement the fix in theDecompressfunction.Assistant
Now let me implement the fix in the
Decompressfunction:Assistant
Now let me verify that callers of
Decompressproperly close the originalresp.Bodywhen the empty-body short-circuit returns a NopCloser that doesn't wrap the original reader. Let me checkrawResponseBodyBytesand its callers.Assistant
Let me verify the close behavior is correct in all paths. The key insight:
decompressedResponseBodyusescloseBothwhich closesoriginal(resp.Body) separately, so the empty-body NopCloser not wrapping the original is fine.rawResponseBodyBytesanddecodeBodycallers closeresp.Bodyviadefer. Now let me run the reproduction tests.Assistant
All three decompressors now handle empty input. Let me run the output reproduction test:
Assistant
The fix works. Now let me also test an end-to-end scenario with a DELETE returning 204 and gzip encoding, and verify the raw body path and decompressed path work too.
Assistant
All tests pass including the regression guard for valid non-empty gzip. Now let me run the existing test suites to make sure I didn't break anything.
Assistant
All existing tests pass. Now let me clean up my temporary test files and run the full test suite once more.
Assistant
Good, only the source file is modified. Now let me run the broader test suite to be safe.
Assistant
All tests pass. Let me also check there are no other direct gzip/decompressor usages that bypass the registry's
Decompressmethod.Assistant
The
plugin_install.gousage is for a non-empty tar.gz archive, unrelated to this issue. All HTTP response decompression goes through the registry'sDecompressmethod, which I've fixed. Let me review the final diff.Assistant
The diff is clean and minimal. Let me also run a quick CLI-level integration test to confirm the end-to-end behavior, simulating a DELETE returning 204 with gzip encoding.
Assistant
Let me write a CLI-level integration test to confirm the end-to-end DELETE 204 with gzip scenario works.
Assistant
The important thing is the command ran without error (no "Parse response error"). The empty stdout is expected for a 204 with no body. Let me adjust the test to verify no error and check stderr/status display instead.
Assistant
The command ran without error - that's the key fix. The empty stdout is expected for a 204 with no body. Let me update the test to verify the status is displayed in verbose mode and there's no error.
Assistant
The CLI-level test passes. Let me also verify the raw body output path (
rawResponseBodyBytes) handles empty gzip, since that's another caller ofDecompress.Assistant
The
--rawflag name is wrong. Let me find the correct flag for raw body output.Assistant
Since stdout is a non-TTY buffer, the default already exercises the raw body path (
printRawBodyviarawResponseBodyBytes). Let me remove the invalid--rawflag test and confirm the remaining tests pass.Assistant
Both the raw-body and rendered-body paths work. Now let me clean up the temporary test file and run the full test suite one final time.
Assistant
All tests pass. Let me also run the integration-tagged tests as recommended in AGENTS.md before final commit.
Assistant
All tests pass including the integration tests. Let me review the final diff one more time.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.