Zod records were partial by default in Zod v3.
In v4, To achieve optional keys, use z.partialRecord().
z.partialRecord()
Read the docs on "Records" and the migration guide.