Skip to content

Commit c613e78

Browse files
waleedlatif1claude
andcommitted
fix(okta): prevent silent data loss in update operations
- update_group: always include description in PUT body (defaults to '') since PUT replaces the full profile object - update_user: use !== undefined checks so empty strings can clear fields via Okta's POST partial update - block: allow empty strings through passthrough loop and use !== undefined for groupDescription mapping Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 40e650a commit c613e78

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

apps/sim/blocks/blocks/okta.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ export const OktaBlock: BlockConfig<OktaResponse> = {
289289

290290
// Map group-specific UI fields to tool param names
291291
if (params.groupName) result.name = params.groupName
292-
if (params.groupDescription) result.description = params.groupDescription
292+
if (params.groupDescription !== undefined) result.description = params.groupDescription
293293

294294
// Pass through all other non-empty params
295+
// Allow empty strings so users can clear fields (e.g. update_user partial updates)
295296
const skipKeys = new Set([
296297
'operation',
297298
'apiKey',
@@ -301,7 +302,7 @@ export const OktaBlock: BlockConfig<OktaResponse> = {
301302
'groupDescription',
302303
])
303304
for (const [key, value] of Object.entries(params)) {
304-
if (!skipKeys.has(key) && value !== undefined && value !== null && value !== '') {
305+
if (!skipKeys.has(key) && value !== undefined && value !== null) {
305306
result[key] = value
306307
}
307308
}

apps/sim/tools/okta/update_group.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ export const oktaUpdateGroupTool: ToolConfig<OktaUpdateGroupParams, OktaUpdateGr
6161
Accept: 'application/json',
6262
'Content-Type': 'application/json',
6363
}),
64-
body: (params) => {
65-
const profile: Record<string, string> = { name: params.name }
66-
if (params.description) profile.description = params.description
67-
return { profile }
68-
},
64+
body: (params) => ({
65+
profile: {
66+
name: params.name,
67+
description: params.description ?? '',
68+
},
69+
}),
6970
},
7071

7172
transformResponse: async (response: Response) => {

apps/sim/tools/okta/update_user.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ export const oktaUpdateUserTool: ToolConfig<OktaUpdateUserParams, OktaUpdateUser
9393
body: (params) => {
9494
const profile: Record<string, string> = {}
9595

96-
if (params.firstName) profile.firstName = params.firstName
97-
if (params.lastName) profile.lastName = params.lastName
98-
if (params.email) profile.email = params.email
99-
if (params.login) profile.login = params.login
100-
if (params.mobilePhone) profile.mobilePhone = params.mobilePhone
101-
if (params.title) profile.title = params.title
102-
if (params.department) profile.department = params.department
96+
if (params.firstName !== undefined) profile.firstName = params.firstName
97+
if (params.lastName !== undefined) profile.lastName = params.lastName
98+
if (params.email !== undefined) profile.email = params.email
99+
if (params.login !== undefined) profile.login = params.login
100+
if (params.mobilePhone !== undefined) profile.mobilePhone = params.mobilePhone
101+
if (params.title !== undefined) profile.title = params.title
102+
if (params.department !== undefined) profile.department = params.department
103103

104104
return { profile }
105105
},

0 commit comments

Comments
 (0)