mastra-ai/mastra · error

${this.model.modelId} does not support zod type: ${value.con

Error message

${this.model.modelId} does not support zod type: ${value.constructor.name}

What it means

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.

Source

Thrown at packages/schema-compat/src/schema-compatibility-v4.ts:384

    } else {
      return description;
    }
  }

  /**
   * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
   *
   * @param value - The Zod type to check
   * @param throwOnTypes - Array of type names to throw errors for
   * @returns The original value if not in the throw list
   * @throws Error if the type is in the unsupported list
   */
  public defaultUnsupportedZodTypeHandler<T extends z.ZodObject<any, any>>(
    value: z.ZodAny,
    throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,
  ): ShapeValue<T> {
    if (throwOnTypes.includes(value.constructor.name as UnsupportedZodType)) {
      throw new Error(`${this.model.modelId} does not support zod type: ${value.constructor.name}`);
    }
    return value as ShapeValue<T>;
  }

  /**
   * Default handler for Zod array types. Processes array constraints according to provider support.
   *
   * @param value - The Zod array to process
   * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
   * @returns The processed Zod array
   */
  public defaultZodArrayHandler(
    value: ZodArray<any>,
    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,
  ): ZodArray<any> {
    const zodArrayDef = value._zod.def;
    const processedType = this.processZodType(zodArrayDef.element);

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Replace the unsupported construct with a provider-representable type (plain object/string/number/array fields).
  2. Consult the adapter's UNSUPPORTED_ZOD_TYPES for the exact constructor names to avoid for that model.
  3. Move async/refine/transform logic out of the schema into code around the model call.
  4. Switch to a model/provider whose schema support covers your schema's constructs.

Example fix

// before
const schema = z.object({ tags: z.set(z.string()) });
// after
const schema = z.object({ tags: z.array(z.string()) });
Defensive patterns

Strategy: validation

Validate before calling

import { UNSUPPORTED_ZOD_TYPES } from '@mastra/schema-compat';
function assertSupportedV4(schema: z.ZodObject<any>) {
  for (const field of Object.values(schema.shape)) {
    if (UNSUPPORTED_ZOD_TYPES.includes(field.constructor.name)) {
      throw new TypeError(`Field type ${field.constructor.name} unsupported for this model`);
    }
  }
}

Type guard

function isSupportedZodV4Type(v: z.ZodTypeAny, list: readonly string[]): boolean {
  return !list.includes(v.constructor.name);
}

Try / catch

try {
  processed = compat.process(schema);
} catch (e) {
  if ((e as Error).message.includes('does not support zod type')) {
    throw new Error(`Simplify schema for ${model.modelId}: ${e.message}`, { cause: e });
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/ee06d1a7d289c2b5. Report an issue: GitHub.