{"record":{"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":529,"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":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/colinhacks/zod/blob/2d90846af918af9602e088812d63a035d47cdbe4/packages/zod/src/v4/classic/from-json-schema.ts#L511-L547","documentation":"Thrown by the default branch of the type switch in convertBaseSchema (packages/zod/src/v4/classic/from-json-schema.ts:529) when schema.type is a string the converter does not handle. The converter supports exactly: string, number, integer, boolean, null, object, array (type arrays are expanded into a union before the switch, so only single-string types reach it). Any other value — a typo, a custom vocabulary type, or a non-standard draft keyword — falls through to this guard.","triggerScenarios":"Calling fromJSONSchema on a schema whose `type` is something other than the supported set, e.g. `{ type: 'symbol' }`, `{ type: 'bigint' }`, `{ type: 'any' }`, or a typo like `{ type: 'strign' }`. Also triggered by OpenAPI-specific or custom-vocabulary type values that aren't part of the core JSON Schema type set.","commonSituations":"Hand-written schemas with typos in the type field; schemas using non-standard 'type' values from extended vocabularies; documents generated from TypeScript types that map unknown TS types (symbol, function, Date-as-type) onto the type field; OpenAPI extensions inventing type names.","solutions":["Inspect the type value reported in the message and correct it to one of: string, number, integer, boolean, null, object, array.","If the type is a typo (e.g. 'strign'), fix the source document.","If the type represents a concept Zod has no equivalent for, replace the subschema with an inline schema Zod can express (e.g. use z.any() or a refined z.string() for custom types).","Pre-scan the document for type values outside the supported set and log them before conversion."],"exampleFix":"// before\nconst schema = { type: 'strign', minLength: 1 };\nfromJSONSchema(schema); // throws: Unsupported type: strign\n\n// after\nconst schema = { type: 'string', minLength: 1 };\nfromJSONSchema(schema);","handlingStrategy":"validation","validationCode":"const SUPPORTED_TYPES = new Set(['string', 'number', 'integer', 'boolean', 'null', 'object', 'array']);\n\nfunction assertSupportedTypes(root: unknown) {\n  const visit = (node: unknown): void => {\n    if (Array.isArray(node)) return node.forEach(visit);\n    if (!node || typeof node !== 'object') return;\n    const o = node as Record<string, unknown>;\n    if (typeof o.type === 'string' && !SUPPORTED_TYPES.has(o.type)) {\n      throw new Error(`Unsupported JSON Schema type: '${o.type}'`);\n    }\n    for (const v of Object.values(o)) visit(v);\n  };\n  visit(root);\n}","typeGuard":"function isSupportedType(type: unknown): type is 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'object' | 'array' {\n  return typeof type === 'string' && ['string', 'number', 'integer', 'boolean', 'null', 'object', 'array'].includes(type);\n}","tryCatchPattern":"null","preventionTips":["Restrict schema.type to the supported set: string, number, integer, boolean, null, object, array.","Spell-check the type field — typos like 'strign' are the most common cause.","Replace non-standard type values with an inline schema Zod can express (z.any(), a refined string, etc.).","Pre-scan the document and log any type value outside the supported set before conversion."],"tags":["json-schema","from-json-schema","conversion","unsupported","type"],"backgroundTag":null,"analyzedSha":"2d90846af918af9602e088812d63a035d47cdbe4","analyzedAt":"2026-08-11T01:21:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}