{"record":{"id":"bc6ebd3d5ad405d7","repo":"mastra-ai/mastra","slug":"this-model-modelid-does-not-support-zod-type","errorCode":null,"errorMessage":"${this.model.modelId} does not support zod type: ${value._def?.typeName}","messagePattern":"(.+?) does not support zod type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/schema-compat/src/schema-compatibility-v3.ts","lineNumber":375,"sourceCode":"    } else {\n      return description;\n    }\n  }\n\n  /**\n   * Default handler for unsupported Zod types. Throws an error for specified unsupported types.\n   *\n   * @param value - The Zod type to check\n   * @param throwOnTypes - Array of type names to throw errors for\n   * @returns The original value if not in the throw list\n   * @throws Error if the type is in the unsupported list\n   */\n  public defaultUnsupportedZodTypeHandler<T extends z.AnyZodObject>(\n    value: z.ZodTypeAny,\n    throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,\n  ): ShapeValue<T> {\n    if (throwOnTypes.includes(value._def?.typeName as UnsupportedZodType)) {\n      throw new Error(`${this.model.modelId} does not support zod type: ${value._def?.typeName}`);\n    }\n    return value as ShapeValue<T>;\n  }\n\n  /**\n   * Default handler for Zod array types. Processes array constraints according to provider support.\n   *\n   * @param value - The Zod array to process\n   * @param handleChecks - Array constraints to convert to descriptions vs keep as validation\n   * @returns The processed Zod array\n   */\n  public defaultZodArrayHandler(\n    value: ZodArray<any, any>,\n    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,\n  ): ZodArray<any, any> {\n    const zodArrayDef = value._def;\n    const processedType = this.processZodType(zodArrayDef.type);\n","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/schema-compat/src/schema-compatibility-v3.ts#L357-L393","documentation":"SchemaCompatibility v3 (Zod v3) processes schemas field-by-field for a given model provider. defaultUnsupportedZodTypeHandler throws when a field's Zod type is in the provider's UNSUPPORTED_ZOD_TYPES list, so unsupported constructs fail fast with the model id and type name instead of producing a broken provider schema.","triggerScenarios":"Calling the schema compatibility layer for a model (e.g. via ZodToVertexSchema/Anthropic converters) with a schema containing a Zod type the provider cannot express — commonly ZodEffects/refine/transform, ZodMap, ZodSet, ZodTuple, etc., for that provider.","commonSituations":"Switching models/providers and a schema that worked on one model now contains types the new one rejects; schemas using `.transform()`, `.refine()`, or Map/Set fields; older providers with strict JSON-schema support.","solutions":["Restructure the schema to remove unsupported Zod types for that provider (e.g. replace refine/transform with plain object fields validated elsewhere).","Check the provider's supported-type list in the relevant schema-compat adapter to see which types to avoid.","Move validation/derivation logic out of the schema into application code around the model call.","Choose a provider/model that supports the schema, or widen the throwOnTypes override if you accept the risk."],"exampleFix":"// before\nconst schema = z.object({ due: z.string().transform(s => new Date(s)) });\n// after\nconst schema = z.object({ due: z.string() });\n// convert in application code: new Date(raw.due)","handlingStrategy":"validation","validationCode":"import { UNSUPPORTED_ZOD_TYPES } from '@mastra/schema-compat';\nfunction assertSupported(schema: z.ZodObject<any>) {\n  for (const field of Object.values(schema.shape)) {\n    const t = (field as any)._def?.typeName;\n    if (t && UNSUPPORTED_ZOD_TYPES.includes(t)) throw new TypeError(`Field type ${t} unsupported for this model`);\n  }\n}","typeGuard":"function isSupportedZodType(v: z.ZodTypeAny, list: readonly string[]): boolean {\n  return !list.includes((v as any)._def?.typeName);\n}","tryCatchPattern":"try {\n  processed = compat.process(schema);\n} catch (e) {\n  if ((e as Error).message.includes('does not support zod type')) {\n    throw new Error(`Adjust schema for ${model.modelId}: ${e.message}`, { cause: e });\n  }\n  throw e;\n}","preventionTips":["Keep model-facing schemas limited to object/string/number/boolean/array/null.","Check the provider adapter's unsupported-type list before adding exotic Zod types.","Run schema-processing unit tests for every model/provider you target."],"tags":["zod","schema","unsupported-type"],"backgroundTag":"unsupported-schema-type","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}