can1357/oh-my-pi · error · Error

Invalid commit type: ${input.type}

Error message

Invalid commit type: ${input.type}

What it means

conventionalAnalysis() normalizes raw model output into a ConventionalAnalysis. The `type` field must resolve via canonicalCommitType() against the configured commit-type vocabulary; anything unrecognized (after trimming/canonicalization) throws. This guards the commit message formatter from emitting invalid conventional-commit types.

Source

Thrown at packages/coding-agent/src/commit/conventional/commit-types.ts:134

		let line = `- ${entry.name}: ${entry.description}`.trimEnd();
		if (entry.hint) line += ` (${entry.hint})`;
		lines.push(line);
	}
	const classifierHint = commitTypesResource.classifier_hint.trim();
	if (classifierHint) lines.push(classifierHint);
	return lines.join("\n");
}

/** Normalize raw model analysis into the conventional commit domain. */
export function conventionalAnalysis(input: {
	type: string;
	scope?: unknown;
	summary?: unknown;
	details?: unknown;
	issueRefs?: unknown;
}): ConventionalAnalysis {
	const type = canonicalCommitType(input.type);
	if (!type) throw new Error(`Invalid commit type: ${input.type}`);
	return {
		type,
		scope: coerceOptionalScope(input.scope),
		summary: typeof input.summary === "string" ? input.summary : undefined,
		details: normalizeDetails(input.details),
		issueRefs: stringsFrom(input.issueRefs),
	};
}

/** Build a normalized conventional commit value. */
export function conventionalCommit(input: {
	type: string;
	scope?: unknown;
	summary: string;
	body?: readonly string[];
	footers?: readonly string[];
}): ConventionalCommit {
	const type = canonicalCommitType(input.type);

View on GitHub (pinned to 9690622007)

Solutions

  1. Check the error text — it prints the exact offending type string
  2. Re-run so the model re-parses with the documented vocabulary (formatTypesDescription injects the list into prompts)
  3. If using a custom commit-types resource, ensure every referenced type exists in it
  4. Fall back to the single-commit flow or fix the plan/analysis JSON by hand before continuing

Example fix

// before
{ "type": "feature", "summary": "add login" }
// after
{ "type": "feat", "summary": "add login" }
Defensive patterns

Strategy: validation

Validate before calling

import { isCommitType } from "./commit-types";
if (!isCommitType(String(analysis.type))) {
  throw new Error(`Model returned unknown type: ${analysis.type}`);
}

Type guard

function isValidType(t: unknown): t is CommitType {
  return typeof t === "string" && canonicalCommitType(t) !== null;
}

Try / catch

try {
  const analysis = conventionalAnalysis(raw);
} catch (err) {
  if (err.message.startsWith("Invalid commit type:")) {
    // re-prompt the model with the allowed type list, or fall back
  } else throw err;
}

Prevention

When it happens

Trigger: The LLM returns an analysis whose type is not in the configured vocabulary — hallucinated types ("feature", "chore-update", "refactoring"), typo'd types, or a type from a custom vocabulary removed from config while old prompts/plans still reference it.

Common situations: Model ignoring the type list in the prompt; custom commit-types resource edited without updating dependent flows; fast-path markdown parsing picking up a wrong heading as the type.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/79a598074e609e23. Report an issue: GitHub.