eyaltoledano/claude-task-master · error
Invalid run ID: ${id2}
Error message
Invalid run ID: ${id2} What it means
compareRunIds() validates both arguments; this throw fires when the SECOND run ID (id2) fails isValidRunId() — i.e. it is not a valid ISO 8601 UTC timestamp string. id1 was already validated successfully at this point.
Source
Thrown at packages/tm-core/src/common/utils/run-id-generator.ts:121
* Can be used as a comparator function for Array.sort().
*
* @param {string} id1 - First run ID to compare
* @param {string} id2 - Second run ID to compare
* @returns {number} Negative if id1 < id2, positive if id1 > id2, zero if equal
* @throws {Error} If either run ID is invalid
*
* @example
* compareRunIds('2024-01-15T10:00:00.000Z', '2024-01-15T11:00:00.000Z') // returns negative number
* ['2024-01-15T14:00:00.000Z', '2024-01-15T10:00:00.000Z'].sort(compareRunIds)
* // returns ['2024-01-15T10:00:00.000Z', '2024-01-15T14:00:00.000Z']
*/
export function compareRunIds(id1: string, id2: string): number {
if (!isValidRunId(id1)) {
throw new Error(`Invalid run ID: ${id1}`);
}
if (!isValidRunId(id2)) {
throw new Error(`Invalid run ID: ${id2}`);
}
// String comparison works for ISO 8601 timestamps
// because they are lexicographically sortable
if (id1 < id2) return -1;
if (id1 > id2) return 1;
return 0;
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Validate id2 with isValidRunId(id2) before calling and regenerate or discard it
- Convert Date objects to ISO strings: id2.toISOString()
- Filter collections with ids.filter(isValidRunId) before sorting
Example fix
// before compareRunIds(id1, new Date()); // Date is not a string // after compareRunIds(id1, new Date().toISOString());
Defensive patterns
Strategy: validation
Validate before calling
if (!isValidRunId(id2)) throw new Error(`Cannot compare invalid second run ID: ${id2}`);
if (id2 instanceof Date) id2 = id2.toISOString(); Type guard
function isStringRunId(v: unknown): v is string {
return typeof v === 'string' && isValidRunId(v);
} Try / catch
try {
return compareRunIds(id1, id2);
} catch (err) {
if (err.message.includes(id2)) {
id2 = new Date().toISOString();
return compareRunIds(id1, id2);
}
throw err;
} Prevention
- Convert Date objects with toISOString() before comparing
- Sanitize data read from external sources (logs, DB) with isValidRunId
- Keep a single ID-format constant shared by generator and validators
When it happens
Trigger: compareRunIds(goodId, 'invalid'); sorting arrays where the second element or later entries are corrupt; passing a Date object or number timestamp instead of a string as id2.
Common situations: Datasets with one malformed record; passing new Date() (a Date, not a string) as id2; IDs truncated by a fixed-width column or log parsing.
Related errors
- Invalid run ID: ${id1}
- MFA_VERIFICATION_FAILED
- Failed to initialize services: ${(error as Error).message}
- Invalid format: ${options.format}. Valid formats are: text,
- Failed to fetch tasks from any tag. First error: ${failedTag
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/7cf2be981b96468d.
Report an issue: GitHub.