diff --git a/.changeset/famous-glasses-clean.md b/.changeset/famous-glasses-clean.md new file mode 100644 index 00000000000..b5749f54a24 --- /dev/null +++ b/.changeset/famous-glasses-clean.md @@ -0,0 +1,7 @@ +--- +'@astrojs/starlight': patch +--- + +Safely handle Zod errors + +Prevents bugs where errors without the `.received` props would through and cause builds to fail unnecessarily. diff --git a/packages/starlight/utils/error-map.ts b/packages/starlight/utils/error-map.ts index 667a91af365..b00ed45b3fd 100644 --- a/packages/starlight/utils/error-map.ts +++ b/packages/starlight/utils/error-map.ts @@ -143,7 +143,7 @@ const errorMap: z.ZodErrorMap = (baseError, ctx) => { }; const getTypeOrLiteralMsg = (error: TypeOrLiteralErrByPathEntry): string => { - if (error.received === 'undefined') return 'Required'; + if (typeof error.received === 'undefined') return 'Required'; const expectedDeduped = new Set(error.expected); switch (error.code) { case 'invalid_type':