Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Fail on HTTP Status 204 (No Content) Hello, I'm using Synadia Cloud…

  1. User

    ISSUE DESCRIPTION

    Fail on HTTP Status 204 (No Content) Hello,

    I'm using Synadia Cloud which has a DELETE API 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 body
    

    In this case, it's expected to have an empty body. Nevertheless, restish fails with the error:

    ERROR: Parse response error
    ERROR: Caught error: EOF
    

    Here 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 +0x370
    

    Interface

    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 git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop 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 submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Now let's check the same issue applies to rawResponseBodyBytes and decompressedResponseBody in http.go, which are used for raw/streaming outputs.

  3. Claude Assistant

    Good, readCloser embeds io.Reader and io.Closer directly (fields named Reader and Closer via embedding), so my struct literal using field names Reader: and Closer: should work since embedded fields can be referenced by type name. Let's build.

  4. Claude Assistant

    Build succeeds. Let's write a quick reproduction script to verify the fix.

  5. Claude Assistant

    The fix works. Now let's test the raw body path and streaming path fixes as well, then run the full test suite.

  6. Claude Assistant

    Good, clean. Now let's run the relevant test suites.

  7. Claude Assistant

    Now let's rebuild and rerun tests.

  8. Claude Assistant

    All tests pass now. Let's run the entire test suite to be thorough.

  9. Claude Assistant

    All tests pass. Now let's write a comprehensive reproduction test simulating the full CLI flow (like the actual issue - a real command through restish get/delete) to validate the fix end-to-end, including the raw print mode too.

  10. Claude Assistant

    The fix resolves the issue end-to-end. Let's remove the temporary test file and run the full suite once more to confirm everything is clean.

  11. Claude Assistant

    All tests pass. Let's review the final diff.

  12. Claude Assistant

    This is a clean, minimal fix. Let me also double check the panic scenario mentioned in the original issue traceback isn't reproducible elsewhere, e.g. maybe there's also a MakeRequestAndFormat type function or similar panic-inducing code path in current codebase structure.

  13. Claude Assistant

    Let's verify the fix indeed resolves what would otherwise fail, by temporarily reverting and running the repro test.

  14. Claude Assistant

    Confirmed: without the fix, it fails with decompressing response: EOF, exactly matching the issue. Now restore the fix and verify it passes.

  15. Claude Assistant

    The fix resolves the exact error from the issue. Now let's clean up the temporary test file and run the full test suite one final time.

  16. Claude Assistant

    All tests pass, the repository builds cleanly, and go vet reports no issues.

  17. Claude Assistant

    Summary

    Root cause: When a server responds with an empty body (e.g., HTTP 204 No Content) but still includes a Content-Encoding: gzip header, restish would immediately try to decompress the (empty) body using gzip.NewReader(). Since gzip.NewReader eagerly reads the gzip header from the stream, it fails with io.EOF on a truly empty reader — even though there's nothing wrong with the response. This surfaced as ERROR: Parse response error / ERROR: Caught error: EOF (and, in the older code referenced by the issue, a panic).

    Fix: In both internal/output/response.go (decodeBody, used for the main formatted response parsing path) and internal/cli/http.go (rawResponseBodyBytes, used for raw body output), I now peek a single byte from the response body via a bufio.Reader before invoking the content-encoding decompressor. If the peek returns io.EOF (i.e., the body is genuinely empty), we short-circuit and treat it as an empty/nil body instead of attempting decompression — regardless of what Content-Encoding header is present. If the peek fails for any other reason, that real I/O error is still correctly propagated.

    I intentionally did not apply the same eager-peek approach to decompressedResponseBody, which is used for streaming (SSE/NDJSON) responses — eagerly peeking there would consume/trigger read errors too early and break the existing "SSE stream error" test surfaces (TestSSEReadErrorFailsCommand), since streaming responses need lazy reads to correctly attribute errors to the stream-reading layer. This is fine because streaming content types wouldn't realistically be paired with 204 No Content responses that this issue is about.

    Verification:

    • Reproduced the bug in isolation using a httptest server returning 204 + Content-Encoding: gzip with no body, confirmed output.Normalize failed with decompressing response: EOF prior to the fix.
    • Confirmed a full CLI run (restish delete <url> against that same 204 gzip-encoded empty-body server) failed the same way before the fix, and succeeds after.
    • Ran the complete existing test suite (go build ./..., go vet ./..., go test ./...) — everything passes, including the SSE/streaming error-handling tests that could have been affected by a naive fix.
    • Removed all temporary reproduction files before finalizing; only the two source files listed above are modified.

    Checklist

    • Reproduced the reported error (decompressing response: EOF / equivalent to the original Caught error: EOF) using a minimal HTTP 204 + gzip Content-Encoding scenario.
    • Confirmed the fix resolves the error — the same reproduction now completes successfully with no error.
    • Considered edge cases: non-gzip encodings (deflate/brotli) with empty bodies (also fixed generally, since the check happens before any encoding-specific decompressor runs), genuine I/O read errors on peek (still correctly propagated, not silently swallowed), and streaming responses (deliberately left as lazy-read to avoid altering their error semantics/tests).
    • Ran the full existing test suite (go test ./...) and confirmed everything passes, including a test that initially broke due to an overly broad first attempt at the fix (I identified and corrected that regression before finalizing).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.