Skip to content

Commit e6c07dc

Browse files
committed
fix(bigquery): address second round of Cursor Bugbot findings
- create_table: validate parsed schema is a non-empty array of field objects with a name, not just syntactically valid JSON - get_query_results: guard timeoutMs with Number.isFinite before appending to the query string, matching maxResults
1 parent 6c44630 commit e6c07dc

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

apps/sim/tools/google_bigquery/create_table.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,18 @@ export const googleBigQueryCreateTableTool: ToolConfig<
7777
try {
7878
fields = typeof params.schema === 'string' ? JSON.parse(params.schema) : params.schema
7979
} catch {
80-
throw new Error('Schema must be valid JSON, e.g. [{"name":"id","type":"STRING"}]')
80+
fields = null
81+
}
82+
if (
83+
!Array.isArray(fields) ||
84+
fields.length === 0 ||
85+
!fields.every(
86+
(f) => f && typeof f === 'object' && typeof (f as { name?: unknown }).name === 'string'
87+
)
88+
) {
89+
throw new Error(
90+
'Schema must be a JSON array of column field definitions, e.g. [{"name":"id","type":"STRING"}]'
91+
)
8192
}
8293

8394
const body: Record<string, unknown> = {

apps/sim/tools/google_bigquery/get_query_results.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ export const googleBigQueryGetQueryResultsTool: ToolConfig<
8383
}
8484
}
8585
if (params.timeoutMs !== undefined && params.timeoutMs !== null) {
86-
url.searchParams.set('timeoutMs', String(Number(params.timeoutMs)))
86+
const timeoutMs = Number(params.timeoutMs)
87+
if (Number.isFinite(timeoutMs) && timeoutMs > 0) {
88+
url.searchParams.set('timeoutMs', String(timeoutMs))
89+
}
8790
}
8891
if (params.location) url.searchParams.set('location', params.location)
8992
if (params.startIndex) url.searchParams.set('startIndex', params.startIndex)

0 commit comments

Comments
 (0)