{"record":{"id":"ee06d1a7d289c2b5","repo":"mastra-ai/mastra","slug":"this-model-modelid-does-not-support-zod-type-ee06d1","errorCode":null,"errorMessage":"${this.model.modelId} does not support zod type: ${value.constructor.name}","messagePattern":"(.+?) does not support zod type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/schema-compat/src/schema-compatibility-v4.ts","lineNumber":384,"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.ZodObject<any, any>>(\n    value: z.ZodAny,\n    throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,\n  ): ShapeValue<T> {\n    if (throwOnTypes.includes(value.constructor.name as UnsupportedZodType)) {\n      throw new Error(`${this.model.modelId} does not support zod type: ${value.constructor.name}`);\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>,\n    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,\n  ): ZodArray<any> {\n    const zodArrayDef = value._zod.def;\n    const processedType = this.processZodType(zodArrayDef.element);\n","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/schema-compat/src/schema-compatibility-v4.ts#L366-L402","documentation":"The Zod v4 variant of defaultUnsupportedZodTypeHandler checks the constructor name of the incoming Zod type (v4 has no `._def.typeName`) against the provider's unsupported list. It throws to fail fast when a field uses a Zod construct the target model provider cannot represent.","triggerScenarios":"Processing a Zod v4 schema for a model whose compatibility adapter marks that constructor (e.g. ZodRefinement, ZodTransform, ZodMap, ZodSet) as unsupported via UNSUPPORTED_ZOD_TYPES.","commonSituations":"Migrating a project to Zod v4 while keeping provider-specific schema processing; schemas with async refinements or transforms; providers with limited structured-output support (e.g. certain Google/Anthropic model configs).","solutions":["Replace the unsupported construct with a provider-representable type (plain object/string/number/array fields).","Consult the adapter's UNSUPPORTED_ZOD_TYPES for the exact constructor names to avoid for that model.","Move async/refine/transform logic out of the schema into code around the model call.","Switch to a model/provider whose schema support covers your schema's constructs."],"exampleFix":"// before\nconst schema = z.object({ tags: z.set(z.string()) });\n// after\nconst schema = z.object({ tags: z.array(z.string()) });","handlingStrategy":"validation","validationCode":"import { UNSUPPORTED_ZOD_TYPES } from '@mastra/schema-compat';\nfunction assertSupportedV4(schema: z.ZodObject<any>) {\n  for (const field of Object.values(schema.shape)) {\n    if (UNSUPPORTED_ZOD_TYPES.includes(field.constructor.name)) {\n      throw new TypeError(`Field type ${field.constructor.name} unsupported for this model`);\n    }\n  }\n}","typeGuard":"function isSupportedZodV4Type(v: z.ZodTypeAny, list: readonly string[]): boolean {\n  return !list.includes(v.constructor.name);\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(`Simplify schema for ${model.modelId}: ${e.message}`, { cause: e });\n  }\n  throw e;\n}","preventionTips":["In Zod v4, avoid refine/transform/map/set in model-facing schemas.","Review UNSUPPORTED_ZOD_TYPES for the target provider after Zod migrations.","Add per-provider schema smoke tests."],"tags":["zod","zod-v4","unsupported-type"],"backgroundTag":"unsupported-schema-type","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}