eyaltoledano/claude-task-master · error
Invalid conventional commit format
Error message
Invalid conventional commit format
What it means
parseCommitMessage in CommitMessageGenerator throws this when a commit message header does not match the Conventional Commits pattern type(scope)!: description (e.g. 'feat: add login'). The regex requires a word-char type, optional parenthesized scope, optional bang, a colon, and a non-empty description.
Source
Thrown at packages/tm-core/src/modules/git/services/commit-message-generator.ts:168
return {
isValid: errors.length === 0,
errors
};
}
/**
* Parse a conventional commit message into its components
*/
parseCommitMessage(message: string): ParsedCommitMessage {
const lines = message.split('\n');
const header = lines[0];
// Parse header: type(scope)!: description
const headerRegex = /^(\w+)(?:\(([^)]+)\))?(!)?:\s*(.+)$/;
const match = header.match(headerRegex);
if (!match) {
throw new Error('Invalid conventional commit format');
}
const [, type, scope, breaking, description] = match;
// Body is everything after the first blank line
const bodyStartIndex = lines.findIndex((line, i) => i > 0 && line === '');
const body =
bodyStartIndex !== -1
? lines
.slice(bodyStartIndex + 1)
.join('\n')
.trim()
: undefined;
return {
type,
scope,
breaking: breaking === '!',View on GitHub (pinned to c0c98d367c)
Solutions
- Rewrite the first line as '<type>[optional scope][!]: <description>', e.g. 'feat(auth): add PKCE login'
- Use a supported type: feat, fix, chore, docs, refactor, test, etc.
- If parsing arbitrary messages, catch this error and treat the message as non-conventional
Example fix
// before
generator.parse('updated stuff'); // throws
// after
generator.parse('chore: updated stuff'); Defensive patterns
Strategy: validation
Validate before calling
const headerRegex = /^(\w+)(?:\(([^)]+)\))?(!)?:\s*(.+)$/;
if (!headerRegex.test(commitMessage.split('\n')[0])) {
// reject or fix message before calling parse
} Type guard
function isConventionalMessage(msg: string): boolean {
return /^(\w+)(\([^)]+\))?(!)?:\s+.+$/.test(msg.split('\n')[0]);
} Try / catch
try {
const parsed = generator.parsed;
} catch (e) {
if ((e as Error).message === 'Invalid conventional commit format') {
// fall back to raw message or prompt for a compliant message
}
} Prevention
- Use commitlint or a commit template to enforce Conventional Commits
- Adopt commitizen/husky to generate compliant messages interactively
- Never feed merge-commit defaults into the parser
When it happens
Trigger: Calling the parsed getter / parseCommitMessage() with a message whose first line lacks 'type: description' form: no colon, empty description, multi-line-first-line text, or a type containing non-word characters (e.g. 'chore(deps):' is fine, but 'fixed things' is not).
Common situations: Hand-written commit messages that don't follow Conventional Commits, merge commit defaults like "Merge branch 'x'", messages that only contain a body, or locale/typo issues like a missing space after the colon is actually fine but 'feat - x' is not.
Related errors
- Failed to fetch tasks from any tag. First error: ${failedTag
- ${authCheck.error}
- projectRoot is required for isGitRepository
- projectRoot is required for getCurrentBranch
- projectRoot is required for getLocalBranches
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/0d5222c86ad7fda7.
Report an issue: GitHub.