eyaltoledano/claude-task-master · error
SET_MODEL_ERROR
SET_MODEL_ERROR
Error message
${error.message} What it means
Catch-all wrapper for any unexpected exception thrown during setModel() execution (after the early validation returns). The original error's message is surfaced under the SET_MODEL_ERROR code — e.g. JSON.parse failures from a corrupted config file, or errors thrown by provider detection, config merging, or writeConfig internals.
Source
Thrown at scripts/modules/task-manager/models.js:772
const successMessage = `Successfully set ${role} model to ${modelId} (Provider: ${determinedProvider})`;
report('info', successMessage);
return {
success: true,
data: {
role,
provider: determinedProvider,
modelId,
message: successMessage,
warning: warningMessage // Include warning in the response data
}
};
} catch (error) {
report('error', `Error setting ${role} model: ${error.message}`);
return {
success: false,
error: {
code: 'SET_MODEL_ERROR',
message: error.message
}
};
}
}
/**
* Get API key status for all known providers.
* @param {Object} [options] - Options for the operation
* @param {Object} [options.session] - Session object containing environment variables (for MCP)
* @param {Function} [options.mcpLog] - MCP logger object (for MCP)
* @param {string} [options.projectRoot] - Project root directory
* @returns {Object} RESTful response with API key status report
*/
async function getApiKeyStatusReport(options = {}) {
const { mcpLog, projectRoot, session } = options;
const report = (level, ...args) => {
if (mcpLog && typeof mcpLog[level] === 'function') {View on GitHub (pinned to c0c98d367c)
Solutions
- Read the reported error.message closely — it is the underlying cause (e.g. 'Unexpected token ... in JSON' means fix the config file).
- Validate/repair .taskmaster/config.json with `node -e "JSON.parse(require('fs').readFileSync('.taskmaster/config.json'))"` or restore it via `task-master init`.
- Run with debug output (DEBUG=task-master* task-master models ...) to get the full stack and identify the failing internal step.
- Update task-master to the latest patch version; if the throw comes from library code, open an issue with the message and command used.
Example fix
// before
$ cat .taskmaster/config.json // { "models": { "main": ..., } } <- trailing comma
// after — remove invalid JSON, then re-run
$ node -e "JSON.parse(require('fs').readFileSync('.taskmaster/config.json','utf8'))"
$ task-master models --set-main --openrouter anthropic/claude-sonnet-4 Defensive patterns
Strategy: try-catch
Validate before calling
try {
JSON.parse(require('fs').readFileSync('.taskmaster/config.json', 'utf8'));
} catch (e) {
throw new Error(`Config file is not valid JSON, fix before calling setModel: ${e.message}`);
} Try / catch
try {
const res = await setModel(modelId, role, projectRoot, options);
if (!res.success && res.error?.code === 'SET_MODEL_ERROR') {
console.error(`setModel failed: ${res.error.message}`); // message names the root cause
}
} catch (e) {
console.error('Unhandled setModel exception:', e);
} Prevention
- Never hand-edit .taskmaster/config.json without re-validating it as JSON afterward.
- Wrap library calls in try/catch and log the full error object, not just the code.
- Keep task-master versions consistent across your tooling to avoid schema drift.
- Commit a known-good config.json template and restore it if the file gets corrupted.
When it happens
Trigger: Any throw inside the try block: getConfig() hitting malformed JSON in .taskmaster/config.json, writeConfig throwing instead of returning falsy, filesystem exceptions (EACCES/ENOENT), or bugs in provider-resolution helpers.
Common situations: Hand-edited config file left with invalid JSON (trailing commas, comments); a partially written config from a previous crash; symlinked config pointing nowhere; an incompatibility between the CLI version and a manually migrated config schema.
Related errors
- API_KEY_STATUS_ERROR
- SET_RESPONSE_LANGUAGE_ERROR
- Failed to parse JSON response: ${parseError.message}. Respon
- Model "${model}" is not available for provider "${this.getNa
- AUTHENTICATION_ERROR
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/2343b680439aaeda.
Report an issue: GitHub.