mastra-ai/mastra · error · Error
${message}
Error message
${message} What it means
The JSON-Schema-to-Zod converter used for dynamic workflows encounters a JSON Schema keyword it cannot translate (from UNSUPPORTED_SCHEMA_KEYS). Depending on onUnsupportedSchema: 'warn' it warns and falls back to z.any(); otherwise (default 'throw') it throws with the descriptive message about the unsupported keyword.
Source
Thrown at packages/core/src/workflows/dynamic/json-schema-to-zod.ts:75
'allOf',
'not',
'$ref',
'patternProperties',
'discriminator',
] as const;
/** Values `z.literal()` can represent — the only const/enum members that survive conversion losslessly. */
function isLiteralValue(v: unknown): v is string | number | boolean | null {
return v === null || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean';
}
/** Throw or warn-and-fallback per `onUnsupportedSchema`, matching the unsupported-keyword behavior. */
function unsupported(message: string, opts: JsonSchemaToZodOptions): z.ZodTypeAny {
if (opts.onUnsupportedSchema === 'warn') {
opts.onUnsupported?.(message);
return z.any();
}
throw new Error(message);
}
function walk(schema: JsonSchema, opts: JsonSchemaToZodOptions): z.ZodTypeAny {
if (!schema || typeof schema !== 'object') return z.any();
for (const key of UNSUPPORTED_SCHEMA_KEYS) {
if (key in schema) {
return unsupported(
`Dynamic workflow schema uses unsupported JSON Schema keyword "${key}". ` +
`This converter only supports the static subset that Zod round-trips through ` +
`standardSchemaToJSONSchema (object, array, string, number, integer, boolean, null, enum, const). ` +
`Simplify the schema or extend jsonSchemaToZod to cover this keyword.`,
opts,
);
}
}
let out: z.ZodTypeAny;View on GitHub (pinned to 75dd419e61)
Solutions
- Simplify the JSON Schema to core keywords (type, properties, required, items, enum).
- Set onUnsupportedSchema: 'warn' (and handle the onUnsupported callback) if the unsupported keyword can safely degrade to z.any().
- Pre-resolve $ref / oneOf / if-then-else into plain object schemas before passing them in.
Example fix
// before
convertJsonSchemaToZod({ type: 'object', properties: { v: { oneOf: [{ type: 'string' }, { type: 'number' }] } } })
// after
convertJsonSchemaToZod({ type: 'object', properties: { v: {} } }, { onUnsupportedSchema: 'warn' }) Defensive patterns
Strategy: try-catch
Validate before calling
const UNSUPPORTED = ['patternProperties','oneOf','anyOf','if','then','else','$ref','dependencies'];
function findUnsupported(schema, hits = []) {
if (!schema || typeof schema !== 'object') return hits;
for (const k of Object.keys(schema)) if (UNSUPPORTED.includes(k)) hits.push(k);
for (const v of Object.values(schema)) if (v && typeof v === 'object') findUnsupported(v, hits);
return hits;
} Try / catch
try {
const zodSchema = convertJsonSchemaToZod(jsonSchema, opts);
} catch (e) {
// fall back to z.any() or simplify the schema and retry
logger.warn(`Schema conversion failed: ${e.message}`);
} Prevention
- Stick to core JSON Schema keywords (type, properties, required, items, enum).
- Set onUnsupportedSchema: 'warn' when graceful degradation is acceptable.
- Pre-resolve $ref/oneOf/if-then-else before conversion.
- Test schema conversion in CI for all workflow schemas.
When it happens
Trigger: Providing a JSON Schema containing advanced/unsupported keywords (e.g. patternProperties, oneOf combinations, if/then/else, $ref, format extensions) as stateSchema or step input/output schema in a dynamic workflow, with onUnsupportedSchema not set to 'warn'.
Common situations: Reusing an existing OpenAPI/JSON Schema with exotic keywords as a workflow schema; auto-generated schemas from API specs containing $ref or nullable variants; upgrading the schema of stored workflows to use newer JSON Schema features the converter doesn't support.
Related errors
- We could not convert the schema to a JSONSchema
- Unsupported JSON Schema target: "${options.target}". Support
- [Schema Builder] Failed to convert schema parameters to Zod.
- OBSERVABILITY_INVALID_CONFIG
- OBSERVABILITY_INVALID_INSTANCE_CONFIG
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/2b160603614c2a1b.
Report an issue: GitHub.