eyaltoledano/claude-task-master · error
Invalid task ID format: "${trimmedId}". Expected format: "15
Error message
Invalid task ID format: "${trimmedId}". Expected format: "15" or "15.2" What it means
Thrown while parsing the --id option of commands that accept comma-separated task/subtask IDs. Each comma-separated token must match /^\d+(\.\d+)?$/ — a plain numeric task id ("15") or one-level subtask id ("15.2"). Anything else aborts the whole command with this message.
Source
Thrown at scripts/modules/commands.js:2109
!validDetailLevels.includes(options.detail.toLowerCase())
) {
console.error(
chalk.red(
`Error: Detail level must be one of: ${validDetailLevels.join(', ')}`
)
);
process.exit(1);
}
// Validate and parse task IDs if provided
let taskIds = [];
if (options.id) {
try {
taskIds = options.id.split(',').map((id) => {
const trimmedId = id.trim();
// Support both task IDs (e.g., "15") and subtask IDs (e.g., "15.2")
if (!/^\d+(\.\d+)?$/.test(trimmedId)) {
throw new Error(
`Invalid task ID format: "${trimmedId}". Expected format: "15" or "15.2"`
);
}
return trimmedId;
});
} catch (error) {
console.error(chalk.red(`Error parsing task IDs: ${error.message}`));
process.exit(1);
}
}
// Validate and parse file paths if provided
let filePaths = [];
if (options.files) {
try {
filePaths = options.files.split(',').map((filePath) => {
const trimmedPath = filePath.trim();
if (trimmedPath.length === 0) {View on GitHub (pinned to c0c98d367c)
Solutions
- Use numeric IDs only: --id=15 or --id=15.2.
- Remove extra dots/characters; sub-subtasks beyond one level are not accepted here.
- Trim whitespace and check for empty tokens between commas in the --id list.
- If the task has a non-numeric ID (HAM-123), that format belongs to Hamster/remote mode — use the appropriate command/mode.
Example fix
// before task-master update-task --id=HAM-12.3 // after task-master update-task --id=12.3
Defensive patterns
Strategy: validation
Validate before calling
function validateTaskIds(idOption) {
return idOption.split(',').map(s => s.trim()).map(s => {
if (!/^\d+(\.\d+)?$/.test(s)) throw new Error(`Invalid task ID format: "${s}". Expected "15" or "15.2"`);
return s;
});
}
validateTaskIds('15,16.2'); Type guard
const isTaskId = (s) => /^\d+(\.\d+)?$/.test(s);
Try / catch
try {
await tm.tasks.update({ id: options.id, prompt });
} catch (e) {
if (e.message.startsWith('Invalid task ID format')) {
console.error(chalk.red(`${e.message}\nUsage: --id=15 or --id=15.2 (comma-separated)`));
process.exit(1);
}
throw e;
} Prevention
- Quote --id values in shell to avoid space/quote artifacts.
- Sanitize IDs from external systems to numeric task ids before passing.
- Remember only one dot level (task.subtask) is accepted.
- Trim and filter empty tokens when assembling comma-separated lists.
When it happens
Trigger: Running a CLI command like `task-master update-task --id=abc` or `--id=15.2.3` or `--id= 15` with non-numeric or multi-dot tokens; also triggered by stray characters like trailing commas producing empty tokens.
Common situations: Paste errors from ticket systems (HAM-123 style IDs), trying to reference sub-subtasks (15.2.1) which this regex rejects, shell quoting issues leaving spaces or quotes in the ID, or scripting with empty ID variables.
Related errors
- Empty file path provided
- MFA_VERIFICATION_FAILED
- No valid task IDs provided
- Invalid task ID format: ${invalidIds.join(', ')}. Expected n
- streamObjectService requires a schema parameter
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/8371ef9717fba2ac.
Report an issue: GitHub.