{"record":{"id":"892885ff562bf460","repo":"colinhacks/zod","slug":"unevaluateditems-is-not-supported","errorCode":null,"errorMessage":"unevaluatedItems is not supported","messagePattern":"unevaluatedItems is not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/zod/src/v4/classic/from-json-schema.ts","lineNumber":157,"sourceCode":"      throw new Error(`Reference not found: ${ref}`);\n    }\n    return ctx.defs[key]!;\n  }\n\n  throw new Error(`Reference not found: ${ref}`);\n}\n\nfunction convertBaseSchema(schema: JSONSchema.JSONSchema, ctx: ConversionContext): ZodType {\n  // Handle unsupported features\n  if (schema.not !== undefined) {\n    // Special case: { not: {} } represents never\n    if (typeof schema.not === \"object\" && Object.keys(schema.not).length === 0) {\n      return z.never();\n    }\n    throw new Error(\"not is not supported in Zod (except { not: {} } for never)\");\n  }\n  if (schema.unevaluatedItems !== undefined) {\n    throw new Error(\"unevaluatedItems is not supported\");\n  }\n  if (schema.unevaluatedProperties !== undefined) {\n    throw new Error(\"unevaluatedProperties is not supported\");\n  }\n  if (schema.if !== undefined || schema.then !== undefined || schema.else !== undefined) {\n    throw new Error(\"Conditional schemas (if/then/else) are not supported\");\n  }\n  if (schema.dependentSchemas !== undefined || schema.dependentRequired !== undefined) {\n    throw new Error(\"dependentSchemas and dependentRequired are not supported\");\n  }\n\n  // Handle $ref\n  if (schema.$ref) {\n    const refPath = schema.$ref;\n    if (ctx.refs.has(refPath)) {\n      return ctx.refs.get(refPath)!;\n    }\n","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/colinhacks/zod/blob/2d90846af918af9602e088812d63a035d47cdbe4/packages/zod/src/v4/classic/from-json-schema.ts#L139-L175","documentation":"Thrown by convertBaseSchema (packages/zod/src/v4/classic/from-json-schema.ts:157) when the source JSON Schema contains the `unevaluatedItems` keyword (a draft-2019+ feature that constrains array items not validated by items/prefixItems/contains). Zod arrays have no notion of 'unevaluated' items tied to composition evaluation, so the converter refuses the document rather than silently dropping the constraint.","triggerScenarios":"Calling fromJSONSchema on a schema that includes `unevaluatedItems`, typically `{ type: 'array', items: {...}, unevaluatedItems: false }` or `unevaluatedItems: { ... }`. Any presence of the key triggers the throw regardless of its value.","commonSituations":"Converting draft-2019/2020-12 schemas authored with unevaluatedItems for strict array validation; schemas generated by strict validators (e.g. ajv with useDefaults/strict mode); OpenAPI 3.1 documents that adopted the 2019-09 vocabulary.","solutions":["Delete the `unevaluatedItems` key from the source schema before conversion (its semantics have no Zod equivalent).","If the intent was strict rejection of extras, model it with z.tuple + .rest(z.never()) or z.array with a maxItems/minItems bound.","Pre-process the document to strip unsupported draft-2019+ keys.","Validate the source schema against the converter's supported feature list before calling fromJSONSchema."],"exampleFix":"// before\nconst schema = {\n  type: 'array',\n  items: { type: 'string' },\n  unevaluatedItems: false,\n};\nfromJSONSchema(schema); // throws\n\n// after — drop the unsupported keyword\nconst schema = { type: 'array', items: { type: 'string' } };\nfromJSONSchema(schema);","handlingStrategy":"validation","validationCode":"function assertNoUnevaluatedItems(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 ('unevaluatedItems' in o) throw new Error('Schema uses unevaluatedItems, which Zod cannot express');\n    for (const v of Object.values(o)) visit(v);\n  };\n  visit(root);\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Remove unevaluatedItems from source schemas before conversion.","Model strict-array intents with z.tuple().rest(z.never()) or additionalItems:false in the source.","Scan draft-2019/2020-12 documents for unevaluated* keywords before conversion.","Keep the converter's supported-keyword list visible at the call site."],"tags":["json-schema","from-json-schema","conversion","unsupported","array"],"backgroundTag":null,"analyzedSha":"2d90846af918af9602e088812d63a035d47cdbe4","analyzedAt":"2026-08-11T01:21:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}