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

  1. Pass an explicit tag: createContextGatherer(projectRoot, 'master')
  2. Resolve the current tag before the call and fall back to a default: const tag = currentTag || 'master'
  3. Ensure a current tag is set in .taskmaster/config.json before invoking
  4. 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

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


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/03334bb8cb353677. Report an issue: GitHub.