{"record":{"id":"79a598074e609e23","repo":"can1357/oh-my-pi","slug":"invalid-commit-type-input-type","errorCode":null,"errorMessage":"Invalid commit type: ${input.type}","messagePattern":"Invalid commit type: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/commit/conventional/commit-types.ts","lineNumber":134,"sourceCode":"\t\tlet line = `- ${entry.name}: ${entry.description}`.trimEnd();\n\t\tif (entry.hint) line += ` (${entry.hint})`;\n\t\tlines.push(line);\n\t}\n\tconst classifierHint = commitTypesResource.classifier_hint.trim();\n\tif (classifierHint) lines.push(classifierHint);\n\treturn lines.join(\"\\n\");\n}\n\n/** Normalize raw model analysis into the conventional commit domain. */\nexport function conventionalAnalysis(input: {\n\ttype: string;\n\tscope?: unknown;\n\tsummary?: unknown;\n\tdetails?: unknown;\n\tissueRefs?: unknown;\n}): ConventionalAnalysis {\n\tconst type = canonicalCommitType(input.type);\n\tif (!type) throw new Error(`Invalid commit type: ${input.type}`);\n\treturn {\n\t\ttype,\n\t\tscope: coerceOptionalScope(input.scope),\n\t\tsummary: typeof input.summary === \"string\" ? input.summary : undefined,\n\t\tdetails: normalizeDetails(input.details),\n\t\tissueRefs: stringsFrom(input.issueRefs),\n\t};\n}\n\n/** Build a normalized conventional commit value. */\nexport function conventionalCommit(input: {\n\ttype: string;\n\tscope?: unknown;\n\tsummary: string;\n\tbody?: readonly string[];\n\tfooters?: readonly string[];\n}): ConventionalCommit {\n\tconst type = canonicalCommitType(input.type);","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/commit/conventional/commit-types.ts#L116-L152","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the error text — it prints the exact offending type string","Re-run so the model re-parses with the documented vocabulary (formatTypesDescription injects the list into prompts)","If using a custom commit-types resource, ensure every referenced type exists in it","Fall back to the single-commit flow or fix the plan/analysis JSON by hand before continuing"],"exampleFix":"// before\n{ \"type\": \"feature\", \"summary\": \"add login\" }\n// after\n{ \"type\": \"feat\", \"summary\": \"add login\" }","handlingStrategy":"validation","validationCode":"import { isCommitType } from \"./commit-types\";\nif (!isCommitType(String(analysis.type))) {\n  throw new Error(`Model returned unknown type: ${analysis.type}`);\n}","typeGuard":"function isValidType(t: unknown): t is CommitType {\n  return typeof t === \"string\" && canonicalCommitType(t) !== null;\n}","tryCatchPattern":"try {\n  const analysis = conventionalAnalysis(raw);\n} catch (err) {\n  if (err.message.startsWith(\"Invalid commit type:\")) {\n    // re-prompt the model with the allowed type list, or fall back\n  } else throw err;\n}","preventionTips":["Keep the type vocabulary in the prompt (formatTypesDescription does this automatically)","Validate model JSON before passing to conventionalAnalysis","Re-run on parse failures — LLM type drift is usually transient"],"tags":["conventional-commits","validation","llm-output"],"backgroundTag":"invalid-commit-type","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}