Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

added transform response to handle non-json responses for internal tools

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 Sep 20, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Building Building Preview Comment Sep 20, 2025 9:13pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 20, 2025 9:13pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR addresses a bug in the internal tools system where all responses were being parsed as JSON, causing failures when tools returned non-JSON content like XML, plain text, or binary data. The fix introduces conditional JSON parsing logic in the handleInternalRequest function within apps/sim/tools/index.ts.

The core change modifies the response handling to check if a tool has a transformResponse function defined. When present, the code skips JSON parsing entirely and sets responseData to null, allowing the custom transform function to handle the raw Response object using appropriate methods like response.text(), response.blob(), or other format-specific parsers. This preserves backward compatibility while enabling tools to process diverse response formats.

The implementation fits well within the existing tools architecture, which already supports custom response transformations through the transformResponse property. The change is minimal and targeted, only affecting the specific code path where JSON parsing was previously mandatory. A comprehensive test case was added to verify XML response handling, demonstrating the fix works correctly for non-JSON content types.

Confidence score: 4/5

  • This PR addresses a clear bug with a focused solution that maintains backward compatibility
  • Score reflects solid implementation with good test coverage, though the manual testing approach could be more comprehensive
  • Pay close attention to the conditional logic in handleInternalRequest to ensure edge cases are properly handled

2 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 708321d into staging Sep 20, 2025
5 of 6 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/handleInternalTool branch September 20, 2025 21:18
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