Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Need to have null body handling in execute tool. e.g. Discord tools killing execution because of errors.

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 22, 2026 1:39am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Added proper handling for HTTP status codes that must not have response bodies (101, 204, 205, 304) by checking the status code before attempting to read the response body. Previously, calling .arrayBuffer() on responses with these status codes would cause errors.

Key changes:

  • Created a nullBodyStatuses Set containing status codes that should have null bodies per HTTP spec
  • Added conditional logic to create Response objects with null body for these status codes
  • Extended the existing 202 handling to also cover 204 at the response parsing stage

Impact:

  • Fixes execution failures in Discord tools (delete message, add reaction) and other APIs that return 204 No Content
  • Aligns with HTTP specification requirements for status codes that prohibit message bodies

Confidence Score: 4/5

  • This PR is safe to merge with low risk
  • The fix correctly addresses a real issue with HTTP spec compliance. The status codes (101, 204, 205, 304) are well-established as requiring null bodies. However, confidence is 4 rather than 5 because the change affects the critical tool execution path and could benefit from additional test coverage to verify behavior with all four null-body status codes
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/tools/index.ts Added proper handling for HTTP status codes that should not have response bodies (101, 204, 205, 304), preventing errors when reading responses from APIs like Discord that return 204 No Content

Sequence Diagram

sequenceDiagram
    participant Tool as Discord/API Tool
    participant Execute as executeToolRequest
    participant Fetch as secureFetchWithPinnedIP
    participant API as External API
    participant Response as Response Handler

    Tool->>Execute: Execute tool request
    Execute->>Fetch: Make HTTP request (DELETE/PUT)
    Fetch->>API: Send request
    API-->>Fetch: 204 No Content (empty body)
    Fetch-->>Execute: secureResponse (status 204)
    
    alt Status in nullBodyStatuses (101, 204, 205, 304)
        Execute->>Response: new Response(null, {status, headers})
        Note over Execute,Response: Skip arrayBuffer() call<br/>to avoid errors
    else Other statuses
        Execute->>Fetch: await arrayBuffer()
        Execute->>Response: new Response(bodyBuffer, {status, headers})
    end
    
    alt response.ok
        Response->>Execute: Parse success response
        alt status === 202 || status === 204
            Execute->>Tool: Return {status}
        else
            Execute->>Response: await response.json()
            Execute->>Tool: Return parsed data
        end
    else !response.ok
        Response->>Execute: Handle error
        Execute->>Tool: Throw error
    end
Loading

cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@icecrasher321 icecrasher321 merged commit d681451 into staging Jan 22, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the fix/null-statuses branch January 22, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants