Skip to content

Commit 56116aa

Browse files
committed
fix tests
1 parent 1d505d9 commit 56116aa

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

apps/sim/blocks/blocks/file.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ describe('FileV4Block', () => {
3838
operation: 'file_fetch',
3939
fileUrl: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD',
4040
})
41-
).toThrow('File URL must be a valid http or https URL')
41+
).toThrow('File URL must use http or https')
42+
})
43+
44+
it('rejects valid URLs with unsupported protocols for fetch', () => {
45+
expect(() =>
46+
buildParams({
47+
operation: 'file_fetch',
48+
fileUrl: 'ftp://example.com/file.pdf',
49+
})
50+
).toThrow('File URL must use http or https')
4251
})
4352
})

apps/sim/blocks/blocks/file.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ const resolveHttpFileUrl = (value: unknown): string => {
5050
throw new Error('File URL is required')
5151
}
5252

53+
let parsed: URL
5354
try {
54-
const parsed = new URL(fileUrl)
55-
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
56-
throw new Error('File URL must use http or https')
57-
}
58-
return fileUrl
55+
parsed = new URL(fileUrl)
5956
} catch {
6057
throw new Error('File URL must be a valid http or https URL')
6158
}
59+
60+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
61+
throw new Error('File URL must use http or https')
62+
}
63+
64+
return fileUrl
6265
}
6366

6467
export const FileBlock: BlockConfig<FileParserOutput> = {

apps/sim/tools/http/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
164164
const responseText = await readResponseTextWithLimit(response, {
165165
maxBytes: MAX_HTTP_RESPONSE_BODY_BYTES,
166166
label: 'HTTP Request response body',
167+
allowNoBodyFallback: true,
167168
})
168169
const data = contentType.includes('application/json') ? JSON.parse(responseText) : responseText
169170

0 commit comments

Comments
 (0)