{"id":"67b843a255d1bf82","repo":"colinhacks/zod","slug":"unsupported-type-type","errorCode":null,"errorMessage":"Unsupported type: ${type}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/zod/src/v4/classic/from-json-schema.ts","lineNumber":527,"sourceCode":"\n        // Apply constraints\n        if (typeof schema.minItems === \"number\") {\n          arraySchema = arraySchema.min(schema.minItems);\n        }\n        if (typeof schema.maxItems === \"number\") {\n          arraySchema = arraySchema.max(schema.maxItems);\n        }\n\n        zodSchema = arraySchema;\n      } else {\n        // No items specified - array of any\n        zodSchema = z.array(z.any());\n      }\n      break;\n    }\n\n    default:\n      throw new Error(`Unsupported type: ${type}`);\n  }\n\n  return zodSchema;\n}\n\nfunction convertSchema(schema: JSONSchema.JSONSchema | boolean, ctx: ConversionContext): ZodType {\n  if (typeof schema === \"boolean\") {\n    return schema ? z.any() : z.never();\n  }\n\n  // Convert base schema first (ignoring composition keywords)\n  let baseSchema = convertBaseSchema(schema, ctx);\n  const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;\n\n  // Process composition keywords LAST (they can appear together)\n  // Handle anyOf - wrap base schema with union\n  if (schema.anyOf && Array.isArray(schema.anyOf)) {\n    const options = schema.anyOf.map((s) => convertSchema(s, ctx));","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/colinhacks/zod/blob/912f0f51b0ced654d0069741e7160834dca742ee/packages/zod/src/v4/classic/from-json-schema.ts#L509-L545","documentation":"Thrown by convertTypeSpecificSchema's default switch case when the JSON Schema `type` is not one of the handled values. The converter supports a fixed set of primitives and rejects anything else rather than silently producing z.unknown().","triggerScenarios":"A schema with `type` set to a value outside the supported set — e.g. custom/extensional types, misspelled types (`'interger'`), or future draft values the converter does not yet know.","commonSituations":"Schema authoring typos; consuming schemas with vendor extensions; mixing OpenAPI-flavoured types; new JSON Schema draft keywords.","solutions":["Correct the `type` to a supported primitive (object, array, string, number, integer, boolean, null).","If the type is genuinely unsupported, drop the `type` keyword and rely on other constraints (enum/const/composition) instead.","Pre-process to map or strip unknown types before conversion."],"exampleFix":"// before\n{ \"type\": \"interger\" } // typo\n\n// after\n{ \"type\": \"integer\" }","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"object\",\"array\",\"string\",\"number\",\"integer\",\"boolean\",\"null\"]);\nfunction assertSupportedType(schema: any) {\n  const t = schema?.type;\n  const types = Array.isArray(t) ? t : [t];\n  for (const ty of types) if (ty != null && !SUPPORTED.has(ty)) throw new Error(`Unsupported type: ${ty}`);\n}","typeGuard":"function isSupportedType(t: unknown): boolean {\n  return t == null || [\"object\",\"array\",\"string\",\"number\",\"integer\",\"boolean\",\"null\"].includes(t as string);\n}","tryCatchPattern":null,"preventionTips":["Validate `type` against the supported set before conversion.","Spell-check types and lint against typos like 'interger'.","Drop unknown types or map them to `any` deliberately."],"tags":["json-schema","type","unsupported","v4","from-json-schema"],"analyzedSha":"912f0f51b0ced654d0069741e7160834dca742ee","analyzedAt":"2026-08-03T17:41:55.908Z","schemaVersion":2}