Skip to content

fix(tools): support stringified HTTP request tables#3565

Open
PlaneInABottle wants to merge 3 commits intosimstudioai:stagingfrom
PlaneInABottle:fix/http-request-stringified-tables
Open

fix(tools): support stringified HTTP request tables#3565
PlaneInABottle wants to merge 3 commits intosimstudioai:stagingfrom
PlaneInABottle:fix/http-request-stringified-tables

Conversation

@PlaneInABottle
Copy link

Summary

  • accept stringified HTTP request params and headers so serialized table data from the UI is handled correctly
  • expand the request typing and URL processing path without breaking the existing array-based inputs
  • add regression tests covering stringified arrays, stringified objects, and the current array/null cases

Accept stored header and query tables after they are reloaded from UI JSON so HTTP requests keep their query strings and URL-encoded body handling intact.
@cursor
Copy link

cursor bot commented Mar 13, 2026

PR Summary

Medium Risk
Moderate risk because it changes how the HTTP request tool parses/builds query parameters and headers, which can affect outbound request formatting; covered by new regression tests including invalid JSON cases.

Overview
Fixes the HTTP request tool to accept headers and params provided as JSON strings (e.g., serialized table data from the UI), in addition to the existing array inputs.

Updates request typing and processUrl to handle string/object query params, and adds a new test suite covering stringified arrays/objects, null/undefined handling, and graceful behavior on invalid JSON. Separately adjusts a workflow execute async route test mock to include AuthType.

Written by Cursor Bugbot for commit af48016. Configure here.

@vercel
Copy link

vercel bot commented Mar 13, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 13, 2026 11:47am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 13, 2026

Greptile Summary

This PR fixes a serialization mismatch where the UI persists HTTP request params and headers as JSON strings (stringified TableRow[] or plain objects), but the tool layer only accepted raw TableRow[]. The fix widens the RequestParams type and the processUrl signature to include string, then delegates all parsing/normalization to the existing transformTable utility which already handled strings, arrays, plain objects, and null.

Key changes:

  • types.ts: params and headers now typed as TableRow[] | string to reflect real UI payloads.
  • utils.ts: processUrl's queryParams parameter widened to TableRow[] | Record<string, any> | string | null; no new branching logic needed since transformTable already handles all arms.
  • request.ts: Two inline comments removed; no behavioural changes.
  • request.stringified.test.ts: New regression suite covering stringified arrays, stringified plain objects, raw arrays, null/undefined, and invalid JSON graceful fallback.
  • route.async.test.ts: Adds missing AuthType enum to the @/lib/auth/hybrid vi.mock so the import doesn't resolve to undefined in tests.

Confidence Score: 4/5

  • This PR is safe to merge — the change is narrow, additive, and covered by regression tests.
  • The fix is minimal and delegates entirely to an existing, already-tested utility (transformTable). All new code paths are covered by the new test file. The one residual awkwardness — Record<string, any> in processUrl's signature being unreachable from RequestParams — is a cosmetic type-alignment issue with no runtime impact, addressed from the previous review thread.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/http/types.ts Extends headers and params on RequestParams to accept string in addition to TableRow[], matching the serialized UI storage format.
apps/sim/tools/http/utils.ts Widens processUrl's queryParams type to include string and Record<string, any>, delegating parsing to transformTable which already handles all three variants; Record<string, any> arm is not reachable from RequestParams but aligns with transformTable's own signature.
apps/sim/tools/http/request.ts Minor comment removal only; logic is unchanged — transformTable and processUrl transparently handle the new string type through their already-widened signatures.
apps/sim/tools/http/request.stringified.test.ts New regression test file covering stringified array params/headers, plain array params/headers, null/undefined fallback, stringified plain-object params/headers, and invalid JSON — good coverage of the new code paths.
apps/sim/app/api/workflows/[id]/execute/route.async.test.ts Adds the AuthType enum to the @/lib/auth/hybrid vi.mock factory so tests that import it as a named export no longer receive undefined.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["RequestParams\nparams / headers: TableRow[] or string"] --> B["processUrl(url, pathParams, queryParams)"]
    A --> C["transformTable(headers)"]

    B --> D{queryParams type?}
    D -->|string| E[JSON.parse via transformTable]
    D -->|"TableRow[]"| F[reduce rows to key/value map]
    D -->|"null / undefined"| H[skip - URL unchanged]

    E --> I{parsed result?}
    I -->|array| F
    I -->|plain object| G[return as-is]
    I -->|invalid JSON| J["return {} - silent fallback"]

    F --> K[encode & append query string to URL]
    G --> K

    C --> M{headers type?}
    M -->|string| N[JSON.parse via transformTable]
    M -->|"TableRow[]"| O[reduce rows to key/value map]
    N --> P[getDefaultHeaders - merge + set Host]
    O --> P
    P --> Q[Return final headers map]
Loading

Last reviewed commit: af48016

@waleedlatif1
Copy link
Collaborator

@cursor review

@waleedlatif1
Copy link
Collaborator

@greptile

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

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