Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging 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
    

    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. Qwen Assistant

    Let me analyze the issue. The problem is that restish fails when receiving an HTTP 204 (No Content) response. The error occurs when trying to decode a gzipped response that has an empty body.

    Let me start by exploring the repository structure to understand the codebase.

  3. Qwen Assistant

    Let me look at the main restish.go file and the internal directory structure.

  4. Qwen Assistant

    Based on the error traceback, the issue is in cli/request.go. Let me look at the relevant files. The error says "Parse response error" and "EOF" when decompressing gzip. The issue is that HTTP 204 responses have no body, but if Content-Encoding: gzip is set, the code tries to decompress an empty body.

  5. Qwen Assistant

    Let me look at the http.go file since it likely handles the response processing:

  6. Qwen Assistant

    Let me search for where the response body is decoded, especially related to gzip decompression and the "Parse response error":

  7. Qwen Assistant

    The error message mentions the old path github.com/danielgtaylor/restish/cli. Let me look at the internal/request directory since that's likely where the HTTP request/response handling is done:

  8. Qwen Assistant

    Now let me look at the internal/content directory since the error is about parsing/decoding the response:

  9. Qwen Assistant

    Now I need to find where the response body is read and decompressed. Let me search for where Decompress is called:

  10. Qwen Assistant

    Let me look at the code around line 667 in http.go where the Decompress is called:

  11. Qwen Assistant

    The issue is clear now. The Decompress function in registry.go is called when the response has a Content-Encoding: gzip header. When the body is empty (HTTP 204), gzip.NewReader(r) returns an error because an empty body is not valid gzip data.

    Let me look at how Decompress handles this:

  12. Qwen Assistant

    Now let me look at where the response is actually processed after being received, especially for HTTP 204 status codes:

  13. Qwen Assistant

    Let me continue reading to see how the response body is processed:

  14. Qwen Assistant

    Let me look at the normalizeHTTPResponse function which reads the body:

  15. Qwen Assistant

    ...

  16. Qwen Assistant

    Now let me look at the output.Normalize function:

  17. Qwen Assistant

    Now I can see the issue clearly. The problem is in the decodeBody function in /restish/internal/output/response.go. When a response has Content-Encoding: gzip but no body (HTTP 204), the code still tries to decompress the body using reg.Decompress(encoding, resp.Body), which calls gzip.NewReader(r). An empty reader is not valid gzip data, so it returns an error (EOF).

    The fix should be: when the response body is empty (e.g., HTTP 204 No Content, or any response with no body), we should skip decompression and just return an empty body.

    Let me check how Go's HTTP handles this - for HTTP 204, the resp.Body might be empty, and we should handle that case:

  18. Qwen Assistant

    Let me look at how the decompression is handled. The issue is that Decompress is called even when the body is empty. Let me first create a test to reproduce the issue:

  19. Qwen Assistant

    Now let me write a test script to reproduce the issue:

  20. Qwen Assistant

    I need to set the GOCACHE environment variable as well.

  21. Qwen Assistant

    Now I see the function is content.Default(). Let me update my test script:

  22. Qwen Assistant

    I've successfully reproduced the issue. The error is "decompressing response: EOF" which happens when trying to decompress an empty body with gzip.

    Now let me fix the issue. The fix should be in decodeBody in /restish/internal/output/response.go. When the body is empty (or has zero content length), we should skip the decompression step and just return nil.

    Looking at the code flow:

    1. decodeBody calls reg.Decompress(encoding, resp.Body)
    2. For gzip, this calls gzip.NewReader(r) on an empty reader
    3. gzip.NewReader returns an error because there's no data to read

    The fix should check if the response body is empty before attempting to decompress. There are several ways to handle this:

    1. Check if Content-Length is 0 or if the status code is 204
    2. Check if reading the body returns EOF immediately
    3. Handle the case in the Decompress function by checking if the reader is empty

    The most robust approach is to handle this in decodeBody - if the body is empty (i.e., reading from it returns EOF immediately), we should skip decompression. Let me look at what approaches are taken:

  23. Qwen Assistant

    The best approach is to modify the Decompress function in registry.go. When the reader has no data (empty body), we should return an empty reader instead of trying to decompress. This handles the case where a server sends Content-Encoding: gzip with an empty body (which is technically allowed for 204 responses).

    Let me look at how Decompress works:

  24. Qwen Assistant

    The cleanest fix is in decodeBody in response.go. Instead of calling Decompress immediately, we should first check if the body is empty. The simplest and most robust approach is:

    1. In decodeBody, if the encoding is set but the body might be empty, we should check for empty body first
    2. Or we can modify the decompressor functions to handle empty input gracefully

    Looking at the issue more carefully - the problem is that when a server returns Content-Encoding: gzip with a 204 No Content response, the body is empty but the decompressor still tries to read gzip header bytes.

    The best fix is to handle this in the individual decompressor functions. They should check if the reader is empty first and return an empty reader if so. Let me implement this:

  25. Qwen Assistant

    Now I understand the code. The best approach is to modify the Decompress function in registry.go to handle empty readers gracefully. When the reader is empty (EOF immediately), we should return an empty reader instead of trying to decompress.

    However, a cleaner approach is to handle this in decodeBody in response.go - we should check if the body is empty before trying to decompress. Let me think about this more carefully:

    The issue is that Decompress receives an io.Reader that could be empty. We can't easily check if a reader is empty without consuming it (unless it's a *bytes.Reader or similar).

    Actually, the best place to fix this is in decodeBody. The approach should be:

    1. If encoding is set, try to decompress
    2. If the decompressor returns immediately with EOF (empty body), that's fine - treat it as no body

    But actually, the gzip reader doesn't fail on creation - it fails when you try to read from it. Let me verify this:

  26. Qwen Assistant

    So gzip.NewReader returns an EOF error immediately when the reader is empty. This is the root cause.

    The fix should be in the Decompress function in registry.go. We need to handle the case where the reader is empty. The cleanest approach is to check for empty readers before calling the decompressor. Since we can't peek at a generic io.Reader without buffering, the best approach is:

    1. Modify each decompressor function to handle empty readers gracefully, OR
    2. Wrap the decompression in a way that handles this case

    Let me modify the decompressor functions to handle empty readers. I'll update the default decompress functions to return an empty reader if the input is empty:

  27. Qwen Assistant

    toolOutput= Mapped line 1 ready for show. </tool_response>

  28. Qwen Assistant

    Let me continue working on the fix for the HTTP 204 No Content issue. I need to scroll down to see the Decompress function and the default decompressor functions.

  29. Qwen Assistant

    I need to continue scrolling to find the Decompress function and the decompressor functions.

  30. Qwen Assistant

    I can see the code is continuing. Let me scroll down more to find the Decompress function and the decompressor functions.

  31. Qwen Assistant

    I found the Decompress function at line 300-312. Now I need to see the default decompressor functions (gzip, brotli, deflate). Let me scroll down more.

  32. Qwen Assistant

    Now I understand the issue. The problem is that when the response body is empty (HTTP 204), the decompressor functions fail because they try to read data that doesn't exist. The fix should be to check if the reader is empty before attempting decompression.

    I'll modify the Decompress function in registry.go to handle empty readers gracefully:

  33. Qwen Assistant

    Now let me test if the fix works by running the test script:

  34. Qwen Assistant

    The fix works. Now let me run the existing tests to make sure I haven't broken anything:

  35. Qwen Assistant

    All content tests pass. Let me also run the output tests and http tests to make sure nothing is broken there.

  36. Qwen Assistant

    Let me run the http tests and also run a broader test suite to make sure nothing is broken.

  37. Qwen Assistant

    Let me continue checking the test results and also run more comprehensive tests to make sure my fix doesn't break anything. I should also test edge cases like:

    1. Empty body with gzip encoding (already tested)
    2. Empty body with brotli encoding
    3. Empty body with deflate encoding
    4. Non-empty body with gzip encoding (should still work)
    5. Non-empty body with brotli encoding (should still work)
    6. Non-empty body with deflate encoding (should still work)

    Let me continue reading the test output and then run additional tests.

  38. Qwen Assistant

    All tests pass. Now let me create a more comprehensive test to verify my fix handles all edge cases (gzip, brotli, deflate, with empty and non-empty bodies):

  39. Qwen Assistant

    All tests pass. Now let me also run the full test suite to make sure I haven't broken anything else:

  40. Qwen Assistant

    The failure is just because of my test files in the root directory conflicting with the package. Let me remove them and run the tests again.

  41. Qwen Assistant

    All tests pass. Let me verify my changes one more time by looking at the diff:

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