can1357/oh-my-pi · error

Generated commit message failed validation: ${generated.vali

Error message

Generated commit message failed validation: ${generated.validationError}

What it means

runLegacyCommitCommand validates the model-generated commit message before committing. If the generated message fails validation (generated.validationError is set) in the non-interactive path, it throws instead of writing an invalid commit. The interactive path only warns; this throw happens when there is no user to correct the message.

Source

Thrown at packages/coding-agent/src/commit/pipeline.ts:55

				return;
			}
			process.stderr.write("No changes to commit.\n");
			return;
		}
		throw error;
	}

	const commitMessage = formatConventionalCommit(generated.commit);
	if (args.dryRun) {
		process.stdout.write("\nGenerated commit message:\n");
		process.stdout.write(`${commitMessage}\n`);
		if (generated.validationError) {
			process.stderr.write(`Warning: generated message requires manual correction: ${generated.validationError}\n`);
		}
		return;
	}
	if (generated.validationError) {
		throw new Error(`Generated commit message failed validation: ${generated.validationError}`);
	}

	if (!args.noChangelog) await updateChangelog(cwd, args);
	try {
		await vcs.requireGit(cwd).commitCreate(commitMessage, {});
	} catch (error) {
		if (vcs.isVcsError(error)) abortOnGitFailure("Commit failed", error);
		throw error;
	}
	process.stdout.write("Commit created.\n");
	if (args.push) await pushOrAbort(cwd);
}

async function updateChangelog(cwd: string, args: CommitCommandArgs): Promise<void> {
	const settings = await Settings.init({ cwd });
	const authStorage = await discoverAuthStorage();
	const registry = new ModelRegistry(authStorage);
	await registry.refresh();

View on GitHub (pinned to 9690622007)

Solutions

  1. Re-run commit generation with a stronger model or regenerate until validation passes.
  2. Write the commit message manually and commit with git directly.
  3. Inspect validationError text and relax/adjust project commit-message conventions if overly strict.
  4. Adjust prompting/temperature settings used by the commit pipeline if consistently failing.

Example fix

// before
omp commit   // throws: Generated commit message failed validation: subject exceeds 72 chars
// after
git commit -m "fix: trim subject to fit conventional limits"
Defensive patterns

Strategy: try-catch

Validate before calling

const SUBJECT_MAX = 72;
function isValidCommitMessage(msg: string): boolean {
  const subject = msg.split("\n")[0];
  return /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?!?: /.test(subject) && subject.length <= SUBJECT_MAX;
}

Type guard

function isGeneratedOk(g: { message: string; validationError?: string | null }): g is { message: string; validationError: undefined } {
  return !g.validationError;
}

Try / catch

try {
  await runLegacyCommitCommand(args);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("Generated commit message failed validation")) {
    process.stderr.write(`${err.message}\nFalling back to manual commit.\n`);
  } else throw err;
}

Prevention

When it happens

Trigger: Running the commit command non-interactively when the LLM output violates message rules — e.g. subject too long, wrong conventional-commit type, multi-line subject, forbidden characters — so the validator sets validationError.

Common situations: Small/weak models producing malformed conventional-commit subjects; hook scripts or bots invoking the commit command in CI where nobody can edit the message; strict project commit lint rules the model doesn't satisfy.

Related errors


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