earendil-works/pi · error · Error

Invalid theme

Error message

Invalid theme "${label}":

What it means

Thrown by parseThemeJson when a custom theme JSON passes syntax parsing but fails semantic validation: required color tokens are missing or schema checks (name, other errors) failed. The message enumerates the missing color tokens and other validation errors.

Solutions

  1. Add every listed missing color token to the theme's "colors" object
  2. Compare against built-in themes dark.json / light.json for valid token names and reference values
  3. Fix any additional schema errors listed under "Other errors" in the message
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/modes/interactive/theme/theme.ts:589 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/3a01908768873e67. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/modes/interactive/theme/theme.ts:589

			const path = error.instancePath || "/";
			otherErrors.push(`  - ${path}: ${error.message}`);
		}

		let errorMessage = `Invalid theme "${label}":\n`;
		if (missingColors.size > 0) {
			errorMessage += "\nMissing required color tokens:\n";
			errorMessage += Array.from(missingColors)
				.sort()
				.map((color) => `  - ${color}`)
				.join("\n");
			errorMessage += '\n\nPlease add these colors to your theme\'s "colors" object.';
			errorMessage += "\nSee the built-in themes (dark.json, light.json) for reference values.";
		}
		if (otherErrors.length > 0) {
			errorMessage += `\n\nOther errors:\n${otherErrors.join("\n")}`;
		}

		throw new Error(errorMessage);
	}

	const themeJson = json as ThemeJson;
	assertThemeNameIsValid(themeJson.name);
	return themeJson;
}

function parseThemeJsonContent(label: string, content: string): ThemeJson {
	let json: unknown;
	try {
		json = JSON.parse(stripBom(content));
	} catch (error) {
		throw new Error(`Failed to parse theme ${label}: ${error}`);
	}
	return parseThemeJson(label, json);
}

function loadThemeJson(name: string): ThemeJson {

View on GitHub (pinned to 4af9d21d3b)