{"record":{"id":"3e124b9f930aaf16","repo":"vercel/ai","slug":"invalid-argument-for-parameter-enumvalues-enum-va-3e124b","errorCode":null,"errorMessage":"Invalid argument for parameter enumValues: Enum values are not supported for object output.","messagePattern":"Invalid argument for parameter enumValues: Enum values are not supported for object output\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-object/validate-object-generation-input.ts","lineNumber":75,"sourceCode":"      throw new InvalidArgumentError({\n        parameter: 'enumValues',\n        value: enumValues,\n        message: 'Enum values are not supported for no-schema output.',\n      });\n    }\n  }\n\n  if (output === 'object') {\n    if (schema == null) {\n      throw new InvalidArgumentError({\n        parameter: 'schema',\n        value: schema,\n        message: 'Schema is required for object 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 object output.',\n      });\n    }\n  }\n\n  if (output === 'array') {\n    if (schema == null) {\n      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({","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/validate-object-generation-input.ts#L57-L93","documentation":"enumValues are only meaningful with output: 'enum'. When output is 'object', the model generates a structured object from the schema, so supplying enumValues is contradictory and the library throws InvalidArgumentError.","triggerScenarios":"Calling generateObject({ model, schema, output: 'object', enumValues: [...] }) or streamObject with the same; omitting output explicitly (defaults to 'object') while passing enumValues also triggers it.","commonSituations":"Generic wrapper that always passes enumValues; refactoring an enum call to object output without removing enumValues; merging option objects where enumValues leaks in from another call.","solutions":["Remove enumValues from the object-output call.","If you need the model to pick one value, change to output: 'enum' with enumValues (no schema).","If choices belong inside the object, model them in the schema (e.g. a z.enum field)."],"exampleFix":"// before\ngenerateObject({ model, schema, output: 'object', enumValues: ['a','b'], prompt });\n// after\ngenerateObject({ model, schema: z.object({ choice: z.enum(['a','b']) }), output: 'object', prompt });","handlingStrategy":"validation","validationCode":"if ((opts.output ?? 'object') === 'object' && opts.enumValues != null) {\n  throw new Error(\"enumValues are only valid with output: 'enum'\");\n}","typeGuard":"function isObjectOptionsWithoutEnum(opts) {\n  return (opts.output ?? 'object') === 'object' && opts.enumValues == null;\n}","tryCatchPattern":"try {\n  return await generateObject(opts);\n} catch (error) {\n  if (InvalidArgumentError.isInstance(error) && error.parameter === 'enumValues') {\n    const { enumValues, ...rest } = opts;\n    return generateObject(rest);\n  }\n  throw error;\n}","preventionTips":["Express allowed values inside the schema with z.enum fields.","Never merge enum-call options into object-call options.","Add an options validator at the boundary of any abstraction layer."],"tags":["invalid-argument","enum-values","object-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"}