{"record":{"id":"28da404ab389b75b","repo":"can1357/oh-my-pi","slug":"generated-commit-message-failed-validation-gene","errorCode":null,"errorMessage":"Generated commit message failed validation: ${generated.validationError}","messagePattern":"Generated commit message failed validation: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/commit/pipeline.ts","lineNumber":55,"sourceCode":"\t\t\t\treturn;\n\t\t\t}\n\t\t\tprocess.stderr.write(\"No changes to commit.\\n\");\n\t\t\treturn;\n\t\t}\n\t\tthrow error;\n\t}\n\n\tconst commitMessage = formatConventionalCommit(generated.commit);\n\tif (args.dryRun) {\n\t\tprocess.stdout.write(\"\\nGenerated commit message:\\n\");\n\t\tprocess.stdout.write(`${commitMessage}\\n`);\n\t\tif (generated.validationError) {\n\t\t\tprocess.stderr.write(`Warning: generated message requires manual correction: ${generated.validationError}\\n`);\n\t\t}\n\t\treturn;\n\t}\n\tif (generated.validationError) {\n\t\tthrow new Error(`Generated commit message failed validation: ${generated.validationError}`);\n\t}\n\n\tif (!args.noChangelog) await updateChangelog(cwd, args);\n\ttry {\n\t\tawait vcs.requireGit(cwd).commitCreate(commitMessage, {});\n\t} catch (error) {\n\t\tif (vcs.isVcsError(error)) abortOnGitFailure(\"Commit failed\", error);\n\t\tthrow error;\n\t}\n\tprocess.stdout.write(\"Commit created.\\n\");\n\tif (args.push) await pushOrAbort(cwd);\n}\n\nasync function updateChangelog(cwd: string, args: CommitCommandArgs): Promise<void> {\n\tconst settings = await Settings.init({ cwd });\n\tconst authStorage = await discoverAuthStorage();\n\tconst registry = new ModelRegistry(authStorage);\n\tawait registry.refresh();","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/commit/pipeline.ts#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run commit generation with a stronger model or regenerate until validation passes.","Write the commit message manually and commit with git directly.","Inspect validationError text and relax/adjust project commit-message conventions if overly strict.","Adjust prompting/temperature settings used by the commit pipeline if consistently failing."],"exampleFix":"// before\nomp commit   // throws: Generated commit message failed validation: subject exceeds 72 chars\n// after\ngit commit -m \"fix: trim subject to fit conventional limits\"","handlingStrategy":"try-catch","validationCode":"const SUBJECT_MAX = 72;\nfunction isValidCommitMessage(msg: string): boolean {\n  const subject = msg.split(\"\\n\")[0];\n  return /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\\(.+\\))?!?: /.test(subject) && subject.length <= SUBJECT_MAX;\n}","typeGuard":"function isGeneratedOk(g: { message: string; validationError?: string | null }): g is { message: string; validationError: undefined } {\n  return !g.validationError;\n}","tryCatchPattern":"try {\n  await runLegacyCommitCommand(args);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Generated commit message failed validation\")) {\n    process.stderr.write(`${err.message}\\nFalling back to manual commit.\\n`);\n  } else throw err;\n}","preventionTips":["Use a model known to follow format instructions for commit generation.","Keep project commit conventions (types, subject length) documented where the pipeline prompt reflects them.","Regenerate or manually edit when the warning variant appears interactively instead of letting it reach non-interactive runs.","Pre-commit commitlint rules should match what the generator validates against to avoid repeated failures."],"tags":["validation","commit","llm-output","cli"],"backgroundTag":"commit-message-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}