fix(ui): keep dashboard schemas working on zod 4

zod 4.6 rejects a missing object key unless its schema is optional, even when the schema itself accepts undefined. The key edit form schema is built from z.custom fields that relied on the old behavior, so an empty or partially filled form failed to validate

Build the schema from its shape with partial(), which makes every field optional the way main does with per-field optional(). The other zod importers type-check unchanged and their tests pass on zod 4.6.6
This commit is contained in:
Yuneng Jiang 2026-10-23 15:20:14 -07:00
parent c5901cef5b
commit 9d85318726
No known key found for this signature in database

View file

@ -121,7 +121,7 @@ export const toKeyEditFormValues = (keyData: KeyResponse): KeyEditFormValues =>
rotation_interval: keyData.rotation_interval,
});
export const keyEditFormSchema = z.object({
const keyEditFormShape = {
key_alias: z.custom<string | undefined>(),
models: z.custom<string[] | undefined>(),
allowed_routes: z.custom<string | undefined>(),
@ -166,7 +166,9 @@ export const keyEditFormSchema = z.object({
disabled_callbacks: z.custom<string[] | undefined>(),
auto_rotate: z.custom<boolean | undefined>(),
rotation_interval: z.custom<string | undefined>(),
});
};
export const keyEditFormSchema = z.object(keyEditFormShape).partial();
export interface MountedFieldGates {
canViewPolicies: boolean;