Skip to content

Commit fcf88e0

Browse files
committed
fix(databricks): throw on invalid JSON params, fix boolean coercion, add expandTasks field
- Throw errors on invalid JSON in jobParameters/notebookParams instead of silently defaulting to {} - Always set boolean params explicitly to prevent string 'false' being truthy - Add missing expandTasks dropdown UI field for list_jobs operation
1 parent 563169c commit fcf88e0

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

apps/sim/blocks/blocks/databricks.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ export const DatabricksBlock: BlockConfig<DatabricksResponse> = {
9090
placeholder: 'Filter by name (case-insensitive)',
9191
condition: { field: 'operation', value: 'list_jobs' },
9292
},
93+
{
94+
id: 'expandTasks',
95+
title: 'Expand Tasks',
96+
type: 'dropdown',
97+
options: [
98+
{ label: 'No', id: 'false' },
99+
{ label: 'Yes', id: 'true' },
100+
],
101+
value: () => 'false',
102+
condition: { field: 'operation', value: 'list_jobs' },
103+
mode: 'advanced',
104+
},
93105
{
94106
id: 'limit',
95107
title: 'Limit',
@@ -321,11 +333,11 @@ Return ONLY the numeric timestamp in milliseconds - no explanations, no extra te
321333
if (params.offset) result.offset = Number(params.offset)
322334
if (params.startTimeFrom) result.startTimeFrom = Number(params.startTimeFrom)
323335
if (params.startTimeTo) result.startTimeTo = Number(params.startTimeTo)
324-
if (params.includeHistory === 'true') result.includeHistory = true
325-
if (params.includeResolvedValues === 'true') result.includeResolvedValues = true
326-
if (params.activeOnly === 'true') result.activeOnly = true
327-
if (params.completedOnly === 'true') result.completedOnly = true
328-
if (params.expandTasks === 'true') result.expandTasks = true
336+
result.includeHistory = params.includeHistory === 'true'
337+
result.includeResolvedValues = params.includeResolvedValues === 'true'
338+
result.activeOnly = params.activeOnly === 'true'
339+
result.completedOnly = params.completedOnly === 'true'
340+
result.expandTasks = params.expandTasks === 'true'
329341
if (params.runType === '') result.runType = undefined
330342
return result
331343
},
@@ -351,6 +363,7 @@ Return ONLY the numeric timestamp in milliseconds - no explanations, no extra te
351363
name: { type: 'string', description: 'Job name filter' },
352364
limit: { type: 'number', description: 'Maximum results to return' },
353365
offset: { type: 'number', description: 'Pagination offset' },
366+
expandTasks: { type: 'boolean', description: 'Include task and cluster details' },
354367
activeOnly: { type: 'boolean', description: 'Only active runs' },
355368
completedOnly: { type: 'boolean', description: 'Only completed runs' },
356369
runType: { type: 'string', description: 'Filter by run type' },

apps/sim/tools/databricks/run_job.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ export const runJobTool: ToolConfig<DatabricksRunJobParams, DatabricksRunJobResp
6464
if (params.jobParameters) {
6565
try {
6666
body.job_parameters = JSON.parse(params.jobParameters)
67-
} catch {
68-
body.job_parameters = {}
67+
} catch (error) {
68+
throw new Error(
69+
`Invalid JSON in jobParameters: ${error instanceof Error ? error.message : 'unknown error'}`
70+
)
6971
}
7072
}
7173
if (params.notebookParams) {
7274
try {
7375
body.notebook_params = JSON.parse(params.notebookParams)
74-
} catch {
75-
body.notebook_params = {}
76+
} catch (error) {
77+
throw new Error(
78+
`Invalid JSON in notebookParams: ${error instanceof Error ? error.message : 'unknown error'}`
79+
)
7680
}
7781
}
7882
if (params.idempotencyToken) body.idempotency_token = params.idempotencyToken

0 commit comments

Comments
 (0)