Skip to content

Commit af48016

Browse files
author
test
committed
test(tools): cover invalid stringified HTTP inputs
1 parent 85ef000 commit af48016

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

apps/sim/tools/http/request.stringified.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,21 @@ describe('HTTP Request Tool - Stringified Params Fix', () => {
9090
)(params)
9191
expect(body).toBe('grant_type=client_credentials')
9292
})
93+
94+
it('should handle invalid JSON strings gracefully', () => {
95+
const params = {
96+
url: 'https://api.example.com/test',
97+
method: 'GET' as const,
98+
params: 'not-valid-json',
99+
headers: '{broken',
100+
}
101+
102+
const url = (requestTool.request.url as (input: RequestParams) => string)(params)
103+
expect(url).toBe('https://api.example.com/test')
104+
105+
const headers = (
106+
requestTool.request.headers as (input: RequestParams) => Record<string, string>
107+
)(params)
108+
expect(headers).toBeDefined()
109+
})
93110
})

apps/sim/tools/http/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const getDefaultHeaders = (
5050
export const processUrl = (
5151
url: string,
5252
pathParams?: Record<string, string>,
53-
queryParams?: TableRow[] | Record<string, unknown> | string | null
53+
queryParams?: TableRow[] | Record<string, any> | string | null
5454
): string => {
5555
if ((url.startsWith('"') && url.endsWith('"')) || (url.startsWith("'") && url.endsWith("'"))) {
5656
url = url.slice(1, -1)

0 commit comments

Comments
 (0)