Title: Bug: URLSearchParams silently corrupts object values to [object Object] · Issue #3109 · simstudioai/sim · GitHub
Open Graph Title: Bug: URLSearchParams silently corrupts object values to [object Object] · Issue #3109 · simstudioai/sim
X Title: Bug: URLSearchParams silently corrupts object values to [object Object] · Issue #3109 · simstudioai/sim
Description: Description When an API block sends a request with Content-Type: application/x-www-form-urlencoded header and the body contains nested objects or arrays, the values are silently corrupted to the literal string [object Object] instead of ...
Open Graph Description: Description When an API block sends a request with Content-Type: application/x-www-form-urlencoded header and the body contains nested objects or arrays, the values are silently corrupted to the li...
X Description: Description When an API block sends a request with Content-Type: application/x-www-form-urlencoded header and the body contains nested objects or arrays, the values are silently corrupted to the li...
Opengraph URL: https://github.com/simstudioai/sim/issues/3109
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: URLSearchParams silently corrupts object values to [object Object]","articleBody":"## Description\nWhen an API block sends a request with `Content-Type: application/x-www-form-urlencoded` header and the body contains nested objects or arrays, the values are silently corrupted to the literal string `[object Object]` instead of being properly serialized.\n\n## Location\n- **File:** `/apps/sim/tools/http/request.ts`\n- **Line:** 130\n- **Code:** `urlencoded.append(key, String(value))`\n\n## Root Cause\nJavaScript's `String()` function calls `Object.prototype.toString()` which returns `[object Object]` for plain objects. When iterating over body entries and converting values to strings, nested objects and arrays are silently corrupted.\n\n```javascript\nString({nested: \"value\"}) // Returns \"[object Object]\"\nString([1, 2, 3]) // Returns \"1,2,3\" (loses array structure)\n```\n\n## Reproduction Steps\n1. Create an API block in a workflow\n2. Configure it with:\n - **Method:** POST\n - **Headers:** `Content-Type: application/x-www-form-urlencoded`\n - **Body:** `{data: {nested: \"value\"}, items: [1, 2, 3]}`\n3. Execute the workflow\n4. Inspect the actual HTTP request sent\n\n## Expected vs Actual\n**Expected body:**\n```\ndata=%7B%22nested%22%3A%22value%22%7D&items=%5B1%2C2%2C3%5D\n(URL-encoded JSON for nested objects/arrays)\n```\n\n**Actual body:**\n```\ndata=%5Bobject%20Object%5D&items=1%2C2%2C3\n(Corrupted: [object Object] and array loses structure)\n```\n\n## Impact\n- **Severity:** HIGH - Data Corruption\n- **Type:** Silent Data Loss\n- **Scope:** Any API integration using form-urlencoded bodies with nested objects/arrays\n- **Silent Failure:** No error message, request appears to succeed but data is corrupted\n\n## Code Context (lines 116-140)\n```typescript\nif (params.body) {\n const parsedHeaders = parseTableData(params.headers)\n const headers = transformTable(parsedHeaders)\n const contentType = headers['Content-Type'] || headers['content-type']\n\n if (\n contentType === 'application/x-www-form-urlencoded' &&\n typeof params.body === 'object'\n ) {\n // Convert JSON object to URL-encoded string\n const urlencoded = new URLSearchParams()\n Object.entries(params.body as Record\u003cstring, unknown>).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n urlencoded.append(key, String(value)) // \u003c-- BUG: String(object) = \"[object Object]\"\n }\n })\n return urlencoded.toString()\n }\n return params.body as Record\u003cstring, any>\n}\n```\n\n## Type Safety Issue\nThe body type signature is `Record\u003cstring, unknown>` which explicitly allows objects as values. The code needs to handle this case properly rather than silently corrupting the data.\n\n## Suggested Fix\nReplace line 130:\n\n**Before:**\n```typescript\nurlencoded.append(key, String(value))\n```\n\n**After:**\n```typescript\nurlencoded.append(\n key,\n typeof value === 'object' ? JSON.stringify(value) : String(value)\n)\n```\n\nThis ensures:\n- Objects are properly JSON serialized\n- Arrays are converted to JSON arrays instead of comma-separated strings\n- Primitive values continue to work as before\n- No data corruption occurs","author":{"url":"https://github.com/PlaneInABottle","@type":"Person","name":"PlaneInABottle"},"datePublished":"2026-02-01T20:32:10Z","url":"https://github.com/simstudioai/sim/issues/3109"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:edc281e1-d1d2-63e8-0ef1-d10433ca8b02 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC0C:295278:B42A11:FE4803:6AFB5979 |
| html-safe-nonce | f59a555977c56712fb52411f76f81ddb68a48e7674da335f891da09ff2287012 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzBDOjI5NTI3ODpCNDJBMTE6RkU0ODAzOjZBRkI1OTc5IiwidmlzaXRvcl9pZCI6IjYwMjgwOTE2OTA5OTA2NTU4NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8327695772783511245be5c2348a48f0fa9f99c1c39a5a27304ce1a0b32f5e47 |
| hovercard-subject-tag | issue:3882885479 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/simstudioai/sim/3109/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afb6a5d4e88b0cea777880ae7ed3d7646dd6dd0057f4fcdbf88873ff044cd161/simstudioai/sim/issues/3109 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afb6a5d4e88b0cea777880ae7ed3d7646dd6dd0057f4fcdbf88873ff044cd161/simstudioai/sim/issues/3109 |
| og:image:alt | Description When an API block sends a request with Content-Type: application/x-www-form-urlencoded header and the body contains nested objects or arrays, the values are silently corrupted to the li... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | PlaneInABottle |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width