eyaltoledano/claude-task-master · error

INVALID_RESPONSE_LANGUAGE

INVALID_RESPONSE_LANGUAGE

Error message

Invalid response language: ${lang}. Must be a non-empty string.

What it means

setResponseLanguage() validates that the requested language is a non-empty, non-whitespace string. Passing anything else (undefined, null, '', ' ', a non-string) returns this structured validation failure before any config is touched.

Source

Thrown at scripts/modules/task-manager/response-language.js:47

	);

	if (!configExists) {
		return {
			success: false,
			error: {
				code: 'CONFIG_MISSING',
				message:
					'The configuration file is missing. Run "task-master init" to create it.'
			}
		};
	}

	// Validate response language
	if (typeof lang !== 'string' || lang.trim() === '') {
		return {
			success: false,
			error: {
				code: 'INVALID_RESPONSE_LANGUAGE',
				message: `Invalid response language: ${lang}. Must be a non-empty string.`
			}
		};
	}

	try {
		const currentConfig = getConfig(projectRoot);
		currentConfig.global.responseLanguage = lang;
		const writeResult = writeConfig(currentConfig, projectRoot);

		if (!writeResult) {
			return {
				success: false,
				error: {
					code: 'WRITE_ERROR',
					message: 'Error writing updated configuration to configuration file'
				}
			};

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Re-run with an explicit language value, e.g. `task-master response-language --set spanish`.
  2. In scripts, guard first: if (typeof lang === 'string' && lang.trim()) await setResponseLanguage(lang, root).
  3. Quote shell values properly (LANG_VALUE="spanish"; --set "$LANG_VALUE") so empty interpolation doesn't produce an empty string.
  4. Check `task-master response-language` (no --set) to see the current setting and accepted value format.

Example fix

// before
await setResponseLanguage(opts.language, projectRoot); // opts.language undefined when flag value omitted
// after
const lang = String(opts.language ?? '').trim();
if (!lang) throw new Error('--set requires a language value, e.g. --set spanish');
await setResponseLanguage(lang, projectRoot);
Defensive patterns

Strategy: validation

Validate before calling

function canSetResponseLanguage(lang) {
  return typeof lang === 'string' && lang.trim() !== '';
}
if (!canSetResponseLanguage(lang)) {
  throw new Error('Pass a language value, e.g. --set spanish');
}
await setResponseLanguage(lang, projectRoot);

Type guard

function isNonEmptyString(v) {
  return typeof v === 'string' && v.trim().length > 0;
}
if (isNonEmptyString(lang)) {
  await setResponseLanguage(lang, projectRoot);
}

Try / catch

const res = await setResponseLanguage(lang, projectRoot);
if (!res.success && res.error?.code === 'INVALID_RESPONSE_LANGUAGE') {
  console.error('Usage: task-master response-language --set <language>');
  process.exitCode = 1;
}

Prevention

When it happens

Trigger: setResponseLanguage(undefined, root) — e.g. `task-master response-language --set` with no value; --set given an empty string via shell quoting (''); a script passing a variable that is unset or a non-string type.

Common situations: CLI flag missing its value so the parsed option is undefined; shell variable interpolation producing an empty string ($LANG unset); YAML/JSON automation scripts sending null; misunderstanding the accepted values (expects language names/strings like 'spanish', 'english').

Related errors


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