eyaltoledano/claude-task-master · error
No valid task IDs provided
Error message
No valid task IDs provided
What it means
parseTaskIds() in tm-core's task-id validation splits a comma-separated ID string, trims and drops empty segments, and throws a plain Error('No valid task IDs provided') if nothing remains. It is an input-validation guard so callers never proceed with an empty ID set.
Source
Thrown at packages/tm-core/src/modules/tasks/validation/task-id.ts:127
*
* @example
* ```typescript
* parseTaskIds("1, 2, 3"); // ["1", "2", "3"]
* parseTaskIds("1.2,3.4"); // ["1.2", "3.4"]
* parseTaskIds("HAM-123"); // ["HAM-123"]
* parseTaskIds("ham1,ham2"); // ["HAM-1", "HAM-2"] (normalized)
* parseTaskIds("invalid"); // throws Error
* parseTaskIds("HAM-1.2"); // throws Error (API subtasks not supported)
* ```
*/
export function parseTaskIds(input: string): string[] {
const ids = input
.split(',')
.map((id) => id.trim())
.filter((id) => id.length > 0);
if (ids.length === 0) {
throw new Error('No valid task IDs provided');
}
const invalidIds = ids.filter((id) => !isValidTaskIdFormat(id));
if (invalidIds.length > 0) {
throw new Error(
`Invalid task ID format: ${invalidIds.join(', ')}. Expected numeric (e.g., '15'), subtask (e.g., '15.2'), or display ID (e.g., 'HAM-123')`
);
}
// Normalize all IDs (e.g., "ham1" → "HAM-1")
return ids.map(normalizeDisplayId);
}
/**
* Extract parent task ID from a subtask ID
*
* @param taskId - Task ID (e.g., "1.2.3")
* @returns Parent ID (e.g., "1") or the original ID if not a subtaskView on GitHub (pinned to c0c98d367c)
Solutions
- Check the ID input is non-empty (after trimming and comma-splitting) before calling parseTaskIds
- Fix the shell/variable that produced an empty value (e.g. `${IDS:?IDS is required}`)
- If empty should be allowed, handle it at the call site before invoking the parser
Example fix
// before
const ids = parseTaskIds(process.env.TASK_IDS ?? ''); // throws when unset
// after
const raw = process.env.TASK_IDS;
if (!raw?.trim()) throw new Error('TASK_IDS env var is required');
const ids = parseTaskIds(raw); Defensive patterns
Strategy: validation
Validate before calling
const raw = (input ?? '').trim();
if (!raw || raw.split(',').every(s => s.trim() === '')) {
throw new Error('Provide at least one task ID');
}
parseTaskIds(raw); // safe to call Type guard
function hasTaskIds(input: string | undefined | null): input is string {
return !!input && input.split(',').some(id => id.trim().length > 0);
} Try / catch
try {
ids = parseTaskIds(rawInput);
} catch (e) {
if (e.message === 'No valid task IDs provided') {
printUsage('--id requires at least one task ID');
process.exitCode = 1;
return;
}
throw e;
} Prevention
- Guard env vars/CLI flags with ${VAR:?} or explicit required checks
- Never pass user selections joined with '' — always trim and drop empties first
- Give CLI flags explicit required:true so the framework rejects empty input
- Validate before invoking the parser in interactive UIs
When it happens
Trigger: Passing an empty string, whitespace-only string, or a string of only commas (e.g. ',,,' or ' , ') to `parseTaskIds()`.
Common situations: CLI flag defaults like `--id ""`; shell variable interpolation that expands to empty (`tm tasks update --id "$IDS"` with unset IDS); UI passing an empty selection array joined into a string.
Related errors
- Invalid task ID format: ${invalidIds.join(', ')}. Expected n
- User prompt content is missing.
- Invalid task ID format: "${trimmedId}". Expected format: "15
- Task ID cannot be empty.
- Prompt cannot be empty unless metadata is provided for updat
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/dd6ceae202cc5c48.
Report an issue: GitHub.