Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(tools): cover invalid stringified HTTP inputs
  • Loading branch information
test committed Mar 13, 2026
commit af48016b747993da1ae032f02455dc8534a31de1
17 changes: 17 additions & 0 deletions apps/sim/tools/http/request.stringified.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,21 @@ describe('HTTP Request Tool - Stringified Params Fix', () => {
)(params)
expect(body).toBe('grant_type=client_credentials')
})

it('should handle invalid JSON strings gracefully', () => {
const params = {
url: 'https://api.example.com/test',
method: 'GET' as const,
params: 'not-valid-json',
headers: '{broken',
}

const url = (requestTool.request.url as (input: RequestParams) => string)(params)
expect(url).toBe('https://api.example.com/test')

const headers = (
requestTool.request.headers as (input: RequestParams) => Record<string, string>
)(params)
expect(headers).toBeDefined()
})
})
2 changes: 1 addition & 1 deletion apps/sim/tools/http/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const getDefaultHeaders = (
export const processUrl = (
url: string,
pathParams?: Record<string, string>,
queryParams?: TableRow[] | Record<string, unknown> | string | null
queryParams?: TableRow[] | Record<string, any> | string | null
): string => {
if ((url.startsWith('"') && url.endsWith('"')) || (url.startsWith("'") && url.endsWith("'"))) {
url = url.slice(1, -1)
Expand Down
Loading