Skip to content

Revert "fix(api): fix api block"#953

Merged
icecrasher321 merged 1 commit intostagingfrom
revert-951-fix/requests
Aug 13, 2025
Merged

Revert "fix(api): fix api block"#953
icecrasher321 merged 1 commit intostagingfrom
revert-951-fix/requests

Conversation

@icecrasher321
Copy link
Collaborator

Reverts #951

@vercel
Copy link

vercel bot commented Aug 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
sim 🔄 Building Preview Comment Aug 13, 2025 4:04am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs ⬜️ Skipped Aug 13, 2025 4:04am

@icecrasher321 icecrasher321 merged commit 8aa0ed1 into staging Aug 13, 2025
3 of 4 checks passed
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 reverts PR #951, which was a bug fix for API block functionality. The revert affects two core files in the tools system that handle HTTP requests and response processing.

In apps/sim/tools/index.ts, the revert removes a response cloning mechanism that was added to prevent "Response body already read" errors. The original fix created responseForTransform = response.clone() to ensure the response body could be read both during error checking (lines 407-414) and later during transformation. Without this cloning, the response body will be consumed during error checking, causing failures when transformResponse tries to read it again.

In apps/sim/tools/http/request.ts, the revert removes enhanced error handling in the HTTP request tool's transformResponse method. The original fix replaced a simple fallback to response.text() with more descriptive error messaging when JSON/text parsing failed. This revert returns to the simpler approach that preserves raw response data but loses valuable debugging context.

Both changes affect core infrastructure used across the application for API integrations. The tools system is fundamental to the platform's ability to interact with external services like GitHub, as evidenced by tools like the GitHub PR reader that rely on proper response handling. The revert suggests the original fix may have introduced unintended side effects or compatibility issues with existing integrations.

Confidence score: 1/5

  • This PR will very likely cause runtime errors due to Response body consumption issues
  • Score reflects high risk of breaking existing API integrations that rely on transformResponse functionality
  • Pay close attention to apps/sim/tools/index.ts where the response cloning removal will cause failures

2 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment on lines 469 to 472
if (tool.transformResponse) {
try {
const data = await tool.transformResponse(responseForTransform, params)
const data = await tool.transformResponse(response, params)
return data
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This will throw 'body already read' error since the response body was consumed at line 408 for error checking

Suggested change
if (tool.transformResponse) {
try {
const data = await tool.transformResponse(responseForTransform, params)
const data = await tool.transformResponse(response, params)
return data
if (tool.transformResponse) {
try {
const data = await tool.transformResponse(responseForErrorCheck, params)
return data

} catch (error) {
// If response body reading fails, we can't retry reading - just use error message
data = `Failed to parse response: ${error instanceof Error ? error.message : String(error)}`
data = await response.text()
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This fallback assumes response.text() can still be called after a failed response.json() call, but response bodies can only be consumed once. This could throw an error.

Suggested change
data = await response.text()
data = `Failed to parse response: ${error instanceof Error ? error.message : String(error)}`

@waleedlatif1 waleedlatif1 mentioned this pull request Aug 13, 2025
Merged
10 tasks
@waleedlatif1 waleedlatif1 deleted the revert-951-fix/requests branch August 15, 2025 17:03
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
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.

1 participant