{"record":{"id":"2b160603614c2a1b","repo":"mastra-ai/mastra","slug":"message-2b1606","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/dynamic/json-schema-to-zod.ts","lineNumber":75,"sourceCode":"  'allOf',\n  'not',\n  '$ref',\n  'patternProperties',\n  'discriminator',\n] as const;\n\n/** Values `z.literal()` can represent — the only const/enum members that survive conversion losslessly. */\nfunction isLiteralValue(v: unknown): v is string | number | boolean | null {\n  return v === null || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean';\n}\n\n/** Throw or warn-and-fallback per `onUnsupportedSchema`, matching the unsupported-keyword behavior. */\nfunction unsupported(message: string, opts: JsonSchemaToZodOptions): z.ZodTypeAny {\n  if (opts.onUnsupportedSchema === 'warn') {\n    opts.onUnsupported?.(message);\n    return z.any();\n  }\n  throw new Error(message);\n}\n\nfunction walk(schema: JsonSchema, opts: JsonSchemaToZodOptions): z.ZodTypeAny {\n  if (!schema || typeof schema !== 'object') return z.any();\n\n  for (const key of UNSUPPORTED_SCHEMA_KEYS) {\n    if (key in schema) {\n      return unsupported(\n        `Dynamic workflow schema uses unsupported JSON Schema keyword \"${key}\". ` +\n          `This converter only supports the static subset that Zod round-trips through ` +\n          `standardSchemaToJSONSchema (object, array, string, number, integer, boolean, null, enum, const). ` +\n          `Simplify the schema or extend jsonSchemaToZod to cover this keyword.`,\n        opts,\n      );\n    }\n  }\n\n  let out: z.ZodTypeAny;","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/dynamic/json-schema-to-zod.ts#L57-L93","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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."],"exampleFix":"// before\nconvertJsonSchemaToZod({ type: 'object', properties: { v: { oneOf: [{ type: 'string' }, { type: 'number' }] } } })\n// after\nconvertJsonSchemaToZod({ type: 'object', properties: { v: {} } }, { onUnsupportedSchema: 'warn' })","handlingStrategy":"try-catch","validationCode":"const UNSUPPORTED = ['patternProperties','oneOf','anyOf','if','then','else','$ref','dependencies'];\nfunction findUnsupported(schema, hits = []) {\n  if (!schema || typeof schema !== 'object') return hits;\n  for (const k of Object.keys(schema)) if (UNSUPPORTED.includes(k)) hits.push(k);\n  for (const v of Object.values(schema)) if (v && typeof v === 'object') findUnsupported(v, hits);\n  return hits;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const zodSchema = convertJsonSchemaToZod(jsonSchema, opts);\n} catch (e) {\n  // fall back to z.any() or simplify the schema and retry\n  logger.warn(`Schema conversion failed: ${e.message}`);\n}","preventionTips":["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."],"tags":["json-schema","zod","schema-conversion"],"backgroundTag":"unsupported-schema-keyword","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}