eyaltoledano/claude-task-master · error

Schema validation failed: ${errors}

Error message

Schema validation failed: ${errors}

What it means

Thrown by PromptManager.loadTemplate after fetching a template when its JSON-Schema validator (this.validatePrompt) returns invalid. The message aggregates all validator errors as 'path: message' pairs (instancePath defaults to 'root'), pinpointing which fields of the template object violate the prompt schema.

Source

Thrown at scripts/modules/prompt-manager.js:144

	 * Load a prompt template from the imported prompts
	 * @private
	 */
	loadTemplate(promptId) {
		// Get template from the map
		const template = this.prompts.get(promptId);

		if (!template) {
			throw new Error(`Prompt template '${promptId}' not found`);
		}

		// Schema validation if available (do this first for detailed errors)
		if (this.validatePrompt && this.validatePrompt !== true) {
			const valid = this.validatePrompt(template);
			if (!valid) {
				const errors = this.validatePrompt.errors
					.map((err) => `${err.instancePath || 'root'}: ${err.message}`)
					.join(', ');
				throw new Error(`Schema validation failed: ${errors}`);
			}
		} else {
			// Fallback basic validation if no schema validation available
			if (!template.id || !template.prompts || !template.prompts.default) {
				throw new Error(
					'Invalid template structure: missing required fields (id, prompts.default)'
				);
			}
		}

		return template;
	}

	/**
	 * Validate parameters against template schema
	 * @private
	 */
	validateParameters(template, variables) {

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Read the interpolated errors list and fix each cited path/field in the template definition.
  2. Validate the template JSON against the prompt schema offline before registering.
  3. Copy a known-good built-in template as the base for custom prompts.
  4. If schema is from an older version, update the template to the current schema.

Example fix

// before (missing prompt text)
{ "id": "task-update", "prompts": {} }
// after
{ "id": "task-update", "prompts": { "default": { "system": "...", "user": "..." } } }
Defensive patterns

Strategy: validation

Validate before calling

function validateTemplateShape(tpl, validatePrompt) {
  if (validatePrompt && validatePrompt !== true) {
    const valid = validatePrompt(tpl);
    if (!valid) {
      const errors = validatePrompt.errors.map(e => `${e.instancePath || 'root'}: ${e.message}`).join(', ');
      throw new Error(`Template '${tpl?.id}' fails schema: ${errors}`);
    }
  }
}
// call before registering: validateTemplateShape(myTemplate, ajvValidate);

Try / catch

try {
  const tpl = promptManager.template(promptId);
} catch (e) {
  if (e.message.startsWith('Schema validation failed:')) {
    console.error('Fix these template fields:', e.message.replace('Schema validation failed: ', ''));
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: Registering/loading a template object whose shape deviates from the prompt schema — wrong types, missing required properties, or unexpected values — then calling template(promptId) with schema validation enabled.

Common situations: Hand-authored or hand-edited custom prompt templates with typos or missing fields, templates written for an older schema version, or JSON with wrong types (e.g. prompts as string instead of object) imported into the manager.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/da46b6b5f01ac078. Report an issue: GitHub.