eyaltoledano/claude-task-master · error
Tag is required
Error message
Tag is required
What it means
createContextGatherer() is a factory that requires a tag because every ContextGatherer instance scopes its context gathering to one task tag. It throws when the tag argument is missing, null, undefined, or an empty string.
Source
Thrown at scripts/modules/utils/contextGatherer.js:968
return sections.join('\n\n');
case 'system-prompt':
return sections.join(' ');
default:
return sections.join('\n\n');
}
}
}
/**
* Factory function to create a context gatherer instance
* @param {string} projectRoot - Project root directory
* @param {string} tag - Tag for the task
* @returns {ContextGatherer} Context gatherer instance
* @throws {Error} If tag is not provided
*/
export function createContextGatherer(projectRoot, tag) {
if (!tag) {
throw new Error('Tag is required');
}
return new ContextGatherer(projectRoot, tag);
}
export default ContextGatherer;
View on GitHub (pinned to c0c98d367c)
Solutions
- Pass an explicit tag: createContextGatherer(projectRoot, 'master')
- Resolve the current tag before the call and fall back to a default: const tag = currentTag || 'master'
- Ensure a current tag is set in .taskmaster/config.json before invoking
- Check where the tag variable is produced and fix the undefined/empty value
Example fix
// before const gatherer = createContextGatherer(projectRoot, currentTag); // after const tag = currentTag || 'master'; const gatherer = createContextGatherer(projectRoot, tag);
Defensive patterns
Strategy: validation
Validate before calling
if (typeof tag !== 'string' || tag.length === 0) {
throw new TypeError('createContextGatherer requires a non-empty tag string');
}
const gatherer = createContextGatherer(projectRoot, tag); Type guard
function hasTag(t) {
return typeof t === 'string' && t.trim().length > 0;
} Try / catch
try {
const gatherer = createContextGatherer(projectRoot, tag);
} catch (err) {
if (err.message === 'Tag is required') {
const fallback = createContextGatherer(projectRoot, 'master');
return fallback;
}
throw err;
} Prevention
- Resolve the current tag (config .taskmaster/config.json) before building the gatherer
- Fall back to 'master' when no tag is configured
- Never call the factory with a possibly-empty variable without a guard
- Create/select a tag early in your flow before gathering context
When it happens
Trigger: Calling createContextGatherer(projectRoot) with only one argument; calling it with a tag variable that is '' or undefined because getCurrentTag()/config resolution failed before the call.
Common situations: A tag was not set in config (no 'current' tag in .taskmaster/config.json) so the resolved tag was empty; refactoring removed the tag argument; calling the factory before tag selection/creation in an interactive flow.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- projectRoot is required for isGitRepository
- projectRoot is required for getCurrentBranch
- projectRoot is required for getLocalBranches
- projectRoot is required for getRemoteBranches
- projectRoot is required for getGitHubRepoInfo
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/03334bb8cb353677.
Report an issue: GitHub.