{"record":{"id":"9dc2c81b4461d1c9","repo":"eyaltoledano/claude-task-master","slug":"schema-is-required-for-object-generation-9dc2c8","errorCode":null,"errorMessage":"Schema is required for object generation","messagePattern":"Schema is required for object generation","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/ai-providers/base-provider.js","lineNumber":497,"sourceCode":"\n\t\t\t// Return the stream result directly\n\t\t\t// The stream result contains partialObjectStream and other properties\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthis.handleError('object streaming', error);\n\t\t}\n\t}\n\n\t/**\n\t * Generates a structured object using the provider's model\n\t */\n\tasync generateObject(params) {\n\t\ttry {\n\t\t\tthis.validateParams(params);\n\t\t\tthis.validateMessages(params.messages);\n\n\t\t\tif (!params.schema) {\n\t\t\t\tthrow new Error('Schema is required for object generation');\n\t\t\t}\n\t\t\tif (!params.objectName) {\n\t\t\t\tthrow new Error('Object name is required for object generation');\n\t\t\t}\n\n\t\t\tlog(\n\t\t\t\t'debug',\n\t\t\t\t`Generating ${this.name} object ('${params.objectName}') with model: ${params.modelId}`\n\t\t\t);\n\n\t\t\tconst client = await this.getClient(params);\n\n\t\t\t// Get Sentry telemetry config with function ID and metadata for better tracing\n\t\t\t// Format: provider.model.command.method.objectName\n\t\t\tconst commandName = params.commandName || 'unknown';\n\t\t\tconst functionId = `${this.name}.${params.modelId}.${commandName}.generateObject.${params.objectName}`;\n\n\t\t\t// Build telemetry metadata for enhanced filtering/grouping in Sentry","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/base-provider.js#L479-L515","documentation":"BaseAIProvider.generateObject produces a typed structured object and requires a schema describing its shape. The error is thrown when params.schema is missing or falsy after message/param validation, before contacting the provider API.","triggerScenarios":"Calling provider.generateObject({ modelId, messages, objectName }) without the schema field, or schema is undefined/null due to failed initialization.","commonSituations":"Building params conditionally; copying a generateText example and adding objectName but not schema; schema import resolving to undefined after a refactor.","solutions":["Supply a valid schema in params.schema (e.g. z.object({...}))","Assert the schema is defined before calling generateObject","Use generateText if structured output is not needed"],"exampleFix":"// before\nawait provider.generateObject({ modelId: 'x', messages, objectName: 'task' });\n// after\nawait provider.generateObject({ modelId: 'x', messages, objectName: 'task', schema: z.object({ title: z.string() }) });","handlingStrategy":"validation","validationCode":"function assertGenerateObjectParams(params) {\n  if (!params?.schema) throw new Error('generateObject requires params.schema');\n  if (!params?.objectName) throw new Error('generateObject requires params.objectName');\n}","typeGuard":"function hasSchema(params) {\n  return typeof params === 'object' && params !== null && params.schema != null;\n}","tryCatchPattern":"try {\n  await provider.generateObject(params);\n} catch (e) {\n  if (e.message === 'Schema is required for object generation') {\n    console.error('params.schema missing; pass a Zod schema');\n  } else throw e;\n}","preventionTips":["Always pass schema and objectName together to generateObject","Validate params in a wrapper before calling the provider","Check that schema imports resolve to defined values after refactors"],"tags":["validation","schema","structured-output"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}