Skip to content

fix(http): serialize nested objects in form-urlencoded body - #3124

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/obj
Feb 3, 2026
Merged

fix(http): serialize nested objects in form-urlencoded body#3124
waleedlatif1 merged 1 commit into
stagingfrom
fix/obj

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Fix URLSearchParams corrupting nested objects/arrays to [object Object]
  • JSON.stringify object values in form-urlencoded body serialization

Fixes#3109

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

vercelBot commented Feb 3, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedFeb 3, 2026 6:23pm

Request Review

@greptile-apps

greptile-appsBot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed URLSearchParams corruption when serializing nested objects/arrays in application/x-www-form-urlencoded request bodies. Previously, objects were converted to [object Object] string. Now uses JSON.stringify for object values while preserving primitive serialization with String().

Changes:

  • Modified request.ts:108-111 to conditionally apply JSON.stringify for object-type values
  • Added test case verifying nested objects serialize to URL-encoded JSON strings (e.g., data=%7B%22nested%22%3A%22value%22%7D)
  • Test confirms arrays are handled correctly (items=%5B1%2C2%2C3%5D)

The fix addresses issue #3109 and includes test coverage that was requested in previous review feedback.

Confidence Score: 4/5

  • Safe to merge with minor consideration for edge cases
  • The implementation correctly fixes the nested object serialization bug and includes proper test coverage. However, there's a potential edge case with circular references in JSON.stringify that could throw errors in rare scenarios. The fix is well-targeted and doesn't introduce breaking changes to existing functionality.
  • No critical files require special attention, though request.ts could benefit from error handling for edge cases

Important Files Changed

FilenameOverview
apps/sim/tools/http/request.tsFixed nested object serialization in form-urlencoded bodies using JSON.stringify, preventing [object Object] corruption
apps/sim/tools/http/request.test.tsAdded comprehensive test coverage for nested objects and arrays in form-urlencoded serialization

Sequence Diagram

sequenceDiagram
participant Client
participant requestTool
participant URLSearchParams
participant fetch
Client->>requestTool: POST with nested body & form-urlencoded header
Note over Client,requestTool: body: {name: 'test', data: {nested: 'value'}, items: [1,2,3]}
requestTool->>requestTool: Check Content-Type header
alt Content-Type is application/x-www-form-urlencoded
requestTool->>URLSearchParams: new URLSearchParams()
loop For each key-value pair
alt value is object
requestTool->>requestTool: JSON.stringify(value)
Note over requestTool: {nested: 'value'} → '{"nested":"value"}'<br/>[1,2,3] → '[1,2,3]'
else value is primitive
requestTool->>requestTool: String(value)
Note over requestTool: 'test' → 'test'
end
requestTool->>URLSearchParams: append(key, stringified_value)
end
URLSearchParams->>requestTool: URL-encoded string
Note over URLSearchParams: 'name=test&data=%7B%22nested%22%3A%22value%22%7D&items=%5B1%2C2%2C3%5D'
end
requestTool->>fetch: HTTP request with serialized body
fetch-->>requestTool: Response
requestTool-->>Client: Result
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment threadapps/sim/tools/http/request.ts
Comment threadapps/sim/tools/http/request.ts
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment threadapps/sim/tools/http/request.ts
@waleedlatif1
waleedlatif1 merged commit 4ca0081 into stagingFeb 3, 2026
20 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/obj branch February 3, 2026 18:58
royceP2 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Mar 3, 2026
Sign up for freeto 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

@waleedlatif1