mastra-ai/mastra · error

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

Error message

${this.model.modelId} does not support zod type: ${value._def?.typeName}

What it means

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.

Source

Thrown at packages/schema-compat/src/schema-compatibility-v3.ts:375

    } 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.AnyZodObject>(
    value: z.ZodTypeAny,
    throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,
  ): ShapeValue<T> {
    if (throwOnTypes.includes(value._def?.typeName as UnsupportedZodType)) {
      throw new Error(`${this.model.modelId} does not support zod type: ${value._def?.typeName}`);
    }
    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, any>,
    handleChecks: readonly ArrayCheckType[] = ALL_ARRAY_CHECKS,
  ): ZodArray<any, any> {
    const zodArrayDef = value._def;
    const processedType = this.processZodType(zodArrayDef.type);

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Restructure the schema to remove unsupported Zod types for that provider (e.g. replace refine/transform with plain object fields validated elsewhere).
  2. Check the provider's supported-type list in the relevant schema-compat adapter to see which types to avoid.
  3. Move validation/derivation logic out of the schema into application code around the model call.
  4. Choose a provider/model that supports the schema, or widen the throwOnTypes override if you accept the risk.

Example fix

// before
const schema = z.object({ due: z.string().transform(s => new Date(s)) });
// after
const schema = z.object({ due: z.string() });
// convert in application code: new Date(raw.due)
Defensive patterns

Strategy: validation

Validate before calling

import { UNSUPPORTED_ZOD_TYPES } from '@mastra/schema-compat';
function assertSupported(schema: z.ZodObject<any>) {
  for (const field of Object.values(schema.shape)) {
    const t = (field as any)._def?.typeName;
    if (t && UNSUPPORTED_ZOD_TYPES.includes(t)) throw new TypeError(`Field type ${t} unsupported for this model`);
  }
}

Type guard

function isSupportedZodType(v: z.ZodTypeAny, list: readonly string[]): boolean {
  return !list.includes((v as any)._def?.typeName);
}

Try / catch

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

Prevention

When it happens

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

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

Related errors


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