Skip to content

Commit 46777ae

Browse files
committed
fix(linkup): treat an unset Max Results (null) as omitted
1 parent b122a27 commit 46777ae

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { searchTool } from '@/tools/linkup/search'
3+
4+
function body(maxResults: unknown) {
5+
return searchTool.request.body?.({
6+
q: 'q',
7+
apiKey: 'k',
8+
depth: 'standard',
9+
outputType: 'searchResults',
10+
maxResults,
11+
} as never) as Record<string, unknown>
12+
}
13+
14+
describe('linkup_search maxResults', () => {
15+
it('omits Max Results when the field was never filled in (null) or left blank', () => {
16+
expect(body(null)).not.toHaveProperty('maxResults')
17+
expect(body('')).not.toHaveProperty('maxResults')
18+
expect(body(undefined)).not.toHaveProperty('maxResults')
19+
})
20+
21+
it('sends a whole number and rejects zero', () => {
22+
expect(body('5').maxResults).toBe(5)
23+
expect(() => body('0')).toThrow(/at least 1/)
24+
})
25+
})

‎apps/sim/tools/linkup/search.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const searchTool: ToolConfig<LinkupSearchParams, LinkupSearchToolResponse
151151

152152
if (params.includeSources !== undefined) body.includeSources = params.includeSources
153153

154-
if (params.maxResults !== undefined && String(params.maxResults).trim() !== '') {
154+
if (params.maxResults != null && String(params.maxResults).trim() !== '') {
155155
const maxResults = Number(params.maxResults)
156156
if (!Number.isInteger(maxResults) || maxResults < 1) {
157157
throw new Error('Linkup Max Results must be a whole number of at least 1')

0 commit comments

Comments
 (0)