Skip to content

Commit aa52f0d

Browse files
committed
fix(apollo): tighten account_bulk_update guard and accept object attrs
1 parent a1103d7 commit aa52f0d

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

apps/sim/tools/apollo/account_bulk_update.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,27 @@ export const apolloAccountBulkUpdateTool: ToolConfig<
6464
}
6565
if (params.name) body.name = params.name
6666
if (params.owner_id) body.owner_id = params.owner_id
67-
if (params.account_attributes && params.account_attributes.length > 0) {
68-
body.account_attributes = params.account_attributes
67+
if (params.account_attributes) {
68+
if (Array.isArray(params.account_attributes)) {
69+
if (params.account_attributes.length > 0) {
70+
body.account_attributes = params.account_attributes
71+
}
72+
} else if (
73+
typeof params.account_attributes === 'object' &&
74+
Object.keys(params.account_attributes).length > 0
75+
) {
76+
body.account_attributes = params.account_attributes
77+
}
78+
}
79+
const hasUpdateFields = body.account_attributes || body.name || body.owner_id
80+
if (!hasUpdateFields) {
81+
throw new Error(
82+
'Apollo account bulk update requires update fields. Provide account_attributes (array of per-account updates with id, or single object paired with account_ids), or pair account_ids with name/owner_id to apply uniformly.'
83+
)
6984
}
7085
if (!body.account_ids && !body.account_attributes) {
7186
throw new Error(
72-
'Apollo account bulk update requires either account_ids or account_attributes to be provided'
87+
'Apollo account bulk update requires account_ids (with name/owner_id) or account_attributes (with embedded ids).'
7388
)
7489
}
7590
return body

apps/sim/tools/apollo/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export interface ApolloAccountBulkUpdateParams extends ApolloBaseParams {
442442
account_ids?: string[]
443443
name?: string
444444
owner_id?: string
445-
account_attributes?: Array<{ id: string; [key: string]: unknown }>
445+
account_attributes?: Array<{ id: string; [key: string]: unknown }> | Record<string, unknown>
446446
}
447447

448448
export interface ApolloAccountBulkUpdateResponse extends ToolResponse {

0 commit comments

Comments
 (0)