{"record":{"id":"8084aa722a67f91c","repo":"mastra-ai/mastra","slug":"unsupported-json-schema-target-options-target","errorCode":null,"errorMessage":"Unsupported JSON Schema target: \"${options.target}\". Supported targets are: ${supportedTargets.join(', ')}","messagePattern":"Unsupported JSON Schema target: \"(.+?)\"\\. Supported targets are: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/schema-compat/src/standard-schema/adapters/zod-v3.ts","lineNumber":40,"sourceCode":" * Converts a Zod schema to JSON Schema using the specified target format.\n *\n * @param zodSchema - The Zod schema to convert\n * @param options - Standard Schema JSON options including the target format\n * @returns The JSON Schema representation\n * @throws Error if the target format is not supported\n *\n * @internal\n */\nfunction convertToJsonSchema<T extends ZodType<any, ZodTypeDef, any>>(\n  zodSchema: T,\n  options: StandardJSONSchemaV1.Options,\n): Record<string, unknown> {\n  const target = TARGET_MAP[options.target];\n\n  if (!target) {\n    // For unknown targets, try to use jsonSchema7 as fallback or throw\n    const supportedTargets = Object.keys(TARGET_MAP);\n    throw new Error(\n      `Unsupported JSON Schema target: \"${options.target}\". ` + `Supported targets are: ${supportedTargets.join(', ')}`,\n    );\n  }\n\n  const jsonSchema = zodToJsonSchemaOriginal(zodSchema, {\n    $refStrategy: 'none',\n    target,\n    override: (def: any) => {\n      // Mark z.date() with x-date for downstream string→Date conversion.\n      // Zod v3 has no z.coerce.date(), so all dates are strict.\n      if (def.typeName === 'ZodDate') {\n        return { type: 'string', format: 'date-time', 'x-date': true };\n      }\n      return ignoreOverride;\n    },\n  });\n\n  traverse(jsonSchema, {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/schema-compat/src/standard-schema/adapters/zod-v3.ts#L22-L58","documentation":"convertToJsonSchema in the zod-v3 standard-schema adapter maps an options.target (e.g. 'jsonSchema7', 'draft-2020-12') to a zod-to-json-schema target. If the target string is not in TARGET_MAP, it throws listing the supported targets, rather than emitting a schema for an unknown dialect.","triggerScenarios":"Calling jsonSchemaConverter / convertToJsonSchema with an options.target value not in the adapter's TARGET_MAP — e.g. a typo like 'jsonschema7', a draft name like 'draft-07', or a target valid for another library but not this one.","commonSituations":"Copy-pasting target strings from other JSON-schema tooling; version changes where a target was renamed; config files where the target is user-supplied and unvalidated.","solutions":["Use one of the targets listed in the error message (e.g. the adapter's canonical 'jsonSchema7').","Check the TARGET_MAP keys in packages/schema-compat/src/standard-schema/adapters/zod-v3.ts for exact spellings.","Normalize/whitelist user- or config-supplied targets before calling the converter.","If you truly need an unsupported dialect, convert to the supported target and post-transform the schema."],"exampleFix":"// before\nconvertToJsonSchema(schema, { target: 'draft-07' });\n// after\nconvertToJsonSchema(schema, { target: 'jsonSchema7' });","handlingStrategy":"validation","validationCode":"const SUPPORTED_TARGETS = ['jsonSchema7', 'jsonSchema2019-09', 'openApi3_0']; // keep in sync with TARGET_MAP\nfunction assertValidTarget(target: string) {\n  if (!SUPPORTED_TARGETS.includes(target)) throw new TypeError(`Unsupported JSON Schema target: ${target}`);\n}","typeGuard":"type SupportedTarget = 'jsonSchema7' | 'jsonSchema2019-09' | 'openApi3_0';\nfunction isSupportedTarget(t: string): t is SupportedTarget {\n  return ['jsonSchema7', 'jsonSchema2019-09', 'openApi3_0'].includes(t);\n}","tryCatchPattern":"try {\n  js = convertToJsonSchema(schema, { target });\n} catch (e) {\n  if ((e as Error).message.includes('Unsupported JSON Schema target')) {\n    js = convertToJsonSchema(schema, { target: 'jsonSchema7' });\n  } else throw e;\n}","preventionTips":["Type target as a union of supported literal strings.","Keep target strings centralized in one constant, not inlined at call sites.","Whitelist/normalize external config targets before conversion."],"tags":["json-schema","configuration","zod"],"backgroundTag":"unsupported-target","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}