Skip to content

Commit 6277550

Browse files
committed
Fix permissions parsing
1 parent 93ceeb1 commit 6277550

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/trueforge/src/truefoundry/TrueFoundryServiceFoundryServerClient.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,18 @@ const PutRemoteAgentResponseSchema = z.object({
6363
});
6464

6565
const AgentPermissionSchema = z.enum(['READ_AGENT', 'MANAGE_AGENT']);
66-
const AgentPermissionsSchema = z.record(z.string(), z.array(AgentPermissionSchema));
67-
6866
export type AgentPermission = z.infer<typeof AgentPermissionSchema>;
67+
68+
/** ServiceFoundry may return grants we do not use; drop them instead of failing. */
69+
const AgentPermissionsSchema = z.record(
70+
z.string(),
71+
z.array(z.string()).transform(permissions =>
72+
permissions.flatMap(permission => {
73+
const parsed = AgentPermissionSchema.safeParse(permission);
74+
return parsed.success ? [parsed.data] : [];
75+
}),
76+
),
77+
);
6978
export type AgentPermissions = z.infer<typeof AgentPermissionsSchema>;
7079

7180
export interface PutRemoteAgentInput {

0 commit comments

Comments
 (0)