eyaltoledano/claude-task-master · error
projectRoot is required for getCurrentTag
Error message
projectRoot is required for getCurrentTag
What it means
getCurrentTag reads .taskmaster/state.json under the project root to report the active tag, falling back to the configured defaultTag. Because it joins paths off projectRoot, the parameter is mandatory and the function throws immediately if it is missing.
Source
Thrown at scripts/modules/utils.js:1763
}
if (uniqueCurrencies.size > 1) {
aggregated.currency = 'Multiple'; // Mark if currencies actually differ
} else if (uniqueCurrencies.size === 1) {
aggregated.currency = [...uniqueCurrencies][0];
}
return aggregated;
}
/**
* @deprecated Use TaskMaster.getCurrentTag() instead
* Gets the current tag from state.json or falls back to defaultTag from config
* @param {string} projectRoot - The project root directory (required)
* @returns {string} The current tag name
*/
function getCurrentTag(projectRoot) {
if (!projectRoot) {
throw new Error('projectRoot is required for getCurrentTag');
}
try {
// Try to read current tag from state.json using fs directly
const statePath = path.join(projectRoot, '.taskmaster', 'state.json');
if (fs.existsSync(statePath)) {
const rawState = fs.readFileSync(statePath, 'utf8');
const stateData = JSON.parse(rawState);
if (stateData && stateData.currentTag) {
return stateData.currentTag;
}
}
} catch (error) {
// Ignore errors, fall back to default
}
// Fall back to defaultTag from config using fs directly
try {View on GitHub (pinned to c0c98d367c)
Solutions
- Pass an explicit projectRoot string: getCurrentTag('/path/to/project')
- Resolve the root first with findProjectRoot() and pass its result
- Guard the call site to skip tag resolution when no root is available (use defaultTag instead)
Example fix
// before const tag = getCurrentTag(); // after const tag = getCurrentTag(findProjectRoot() || process.cwd());
Defensive patterns
Strategy: validation
Validate before calling
if (!projectRoot) throw new Error('projectRoot must be resolved before calling getCurrentTag'); Type guard
const hasRoot = (p) => typeof p === 'string' && p.trim() !== '';
Try / catch
try {
const tag = getCurrentTag(projectRoot);
} catch (e) {
if (e.message === 'projectRoot is required for getCurrentTag') {
const tag = 'master'; // fallback default tag
} else throw e;
} Prevention
- Always resolve project root (findProjectRoot) before tag APIs
- Thread projectRoot through your integration's options explicitly
- Unit-test tag helpers with explicit roots
- Never call tag utilities with possibly-undefined roots
When it happens
Trigger: Calling getCurrentTag(undefined/null/'') — typically from programmatic code that resolved the project root elsewhere and passed nothing, or a caller that ran before root detection succeeded.
Common situations: Custom scripts or integrations calling the util directly without options, refactors removing root-resolution logic upstream, or embedding task-master in tools where cwd isn't a taskmaster project.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- projectRoot is required for resolveTag
- MISSING_PARAMETER
- NOT_IMPLEMENTED
- Failed to get tags: ${error.message}
- Tag ${oldTag} not found - file doesn't exist
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/d844ba75d0208966.
Report an issue: GitHub.