{"record":{"id":"f121edd2a0cef2cb","repo":"vercel/ai","slug":"invalid-argument-for-parameter-schema-schema-is-n-f121ed","errorCode":null,"errorMessage":"Invalid argument for parameter schema: Schema is not supported for enum output.","messagePattern":"Invalid argument for parameter schema: Schema is not supported for enum output\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-object/validate-object-generation-input.ts","lineNumber":103,"sourceCode":"      throw new InvalidArgumentError({\n        parameter: 'schema',\n        value: schema,\n        message: 'Element schema is required for array output.',\n      });\n    }\n\n    if (enumValues != null) {\n      throw new InvalidArgumentError({\n        parameter: 'enumValues',\n        value: enumValues,\n        message: 'Enum values are not supported for array output.',\n      });\n    }\n  }\n\n  if (output === 'enum') {\n    if (schema != null) {\n      throw new InvalidArgumentError({\n        parameter: 'schema',\n        value: schema,\n        message: 'Schema is not supported for enum output.',\n      });\n    }\n\n    if (schemaDescription != null) {\n      throw new InvalidArgumentError({\n        parameter: 'schemaDescription',\n        value: schemaDescription,\n        message: 'Schema description is not supported for enum output.',\n      });\n    }\n\n    if (schemaName != null) {\n      throw new InvalidArgumentError({\n        parameter: 'schemaName',\n        value: schemaName,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/validate-object-generation-input.ts#L85-L121","documentation":"output: 'enum' makes the model select one value from enumValues; it does not use a schema. Passing schema (or an enum zod schema) with enum output is contradictory, so the library throws InvalidArgumentError.","triggerScenarios":"Calling generateObject({ model, output: 'enum', enumValues: [...], schema: someSchema, prompt }) or streamObject with schema set alongside enum output; any non-null schema with output: 'enum' triggers it.","commonSituations":"Previously passing a z.enum(...) schema and then also adding output: 'enum'/enumValues during migration; shared helper that always attaches schema; copy-pasted object-output code changed to enum output.","solutions":["Remove the schema property and keep only enumValues with output: 'enum'.","If a schema is what you need (e.g. z.enum field inside an object), use output: 'object' instead.","Update helpers/wrappers to conditionally attach schema only for object/array output."],"exampleFix":"// before\ngenerateObject({ model, output: 'enum', enumValues: ['a','b'], schema: z.enum(['a','b']), prompt });\n// after\ngenerateObject({ model, output: 'enum', enumValues: ['a','b'], prompt });","handlingStrategy":"validation","validationCode":"if (opts.output === 'enum' && opts.schema != null) {\n  throw new Error(\"schema must be omitted when output is 'enum'; use enumValues\");\n}","typeGuard":"function isEnumOptionsValid(opts) {\n  return opts.output !== 'enum' || (opts.schema == null && opts.enumValues != null);\n}","tryCatchPattern":"try {\n  return await generateObject(opts);\n} catch (error) {\n  if (InvalidArgumentError.isInstance(error) && error.parameter === 'schema' && opts.output === 'enum') {\n    const { schema, ...rest } = opts;\n    return generateObject(rest);\n  }\n  throw error;\n}","preventionTips":["With output: 'enum', specify enumValues only; drop schema and z.enum schemas.","Use output: 'object' if you want the value embedded in a structured object.","Conditionally build options per output mode in helper functions."],"tags":["invalid-argument","schema","enum-output","input-validation"],"backgroundTag":"incompatible-schema-option","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}