{"record":{"id":"5c827e9cb46efb8b","repo":"vercel/ai","slug":"invalid-argument-for-parameter-enumvalues-enum-va-5c827e","errorCode":null,"errorMessage":"Invalid argument for parameter enumValues: Enum values are not supported for array output.","messagePattern":"Invalid argument for parameter enumValues: Enum values are not supported for array output\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-object/validate-object-generation-input.ts","lineNumber":93,"sourceCode":"      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({\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({","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/validate-object-generation-input.ts#L75-L111","documentation":"enumValues apply only to output: 'enum'. With output: 'array' the model produces a JSON array of elements shaped by the element schema, so enumValues is invalid and InvalidArgumentError is thrown.","triggerScenarios":"Calling generateObject({ model, output: 'array', schema, enumValues: [...] }) or streamObject with the same combination.","commonSituations":"Shared options object reused across enum and array calls; converting an enum-generation call to array output without removing enumValues; abstraction layers that always include enumValues.","solutions":["Remove enumValues from the array-output call.","If you need an array of enum values, use output: 'array' with schema: z.enum(['a','b']).","If you need a single enum pick, use output: 'enum' instead."],"exampleFix":"// before\ngenerateObject({ model, output: 'array', schema, enumValues: ['a','b'], prompt });\n// after\ngenerateObject({ model, output: 'array', schema: z.enum(['a','b']), prompt });","handlingStrategy":"validation","validationCode":"if (opts.output === 'array' && opts.enumValues != null) {\n  throw new Error(\"enumValues are only valid with output: 'enum'\");\n}","typeGuard":"function isArrayOptionsWithoutEnum(opts) {\n  return opts.output !== 'array' || 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":["For arrays of enum values use schema: z.enum([...]) with output: 'array'.","Keep enumValues out of shared option factories.","Type options per output mode so invalid combinations fail at compile time."],"tags":["invalid-argument","enum-values","array-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"}