fix: remove deprecated generateTaskFiles calls from MCP tools (#1277)

Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Resolves issue #1271 - MCP Connection Closed Error After Upgrading to v0.27.3
This commit is contained in:
Ralph Khreish
2025-10-06 11:55:26 +02:00
committed by GitHub
parent caee040907
commit 7b5a7c4495
6 changed files with 9 additions and 35 deletions

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Fix MCP connection errors caused by deprecated generateTaskFiles calls. Resolves "Cannot read properties of null (reading 'toString')" errors when using MCP tools for task management operations.

View File

@@ -1,8 +1,5 @@
import path from 'path';
import { log, readJSON, writeJSON, getCurrentTag } from '../utils.js';
import { isTaskDependentOn } from '../task-manager.js';
import generateTaskFiles from './generate-task-files.js';
/**
* Add a subtask to a parent task
@@ -142,11 +139,7 @@ async function addSubtask(
// Write the updated tasks back to the file with proper context
writeJSON(tasksPath, data, projectRoot, tag);
// Generate task files if requested
if (generateFiles) {
log('info', 'Regenerating task files...');
await generateTaskFiles(tasksPath, path.dirname(tasksPath), context);
}
// Note: Task file generation is no longer supported and has been removed
return newSubtask;
} catch (error) {

View File

@@ -6,7 +6,6 @@ import {
setTasksForTag,
traverseDependencies
} from '../utils.js';
import generateTaskFiles from './generate-task-files.js';
import {
findCrossTagDependencies,
getDependentTaskIds,
@@ -142,13 +141,7 @@ async function moveTask(
results.push(result);
}
// Generate files once at the end if requested
if (generateFiles) {
await generateTaskFiles(tasksPath, path.dirname(tasksPath), {
tag: tag,
projectRoot: projectRoot
});
}
// Note: Task file generation is no longer supported and has been removed
return {
message: `Successfully moved ${sourceIds.length} tasks/subtasks`,
@@ -209,12 +202,7 @@ async function moveTask(
// The writeJSON function will filter out _rawTaggedData automatically
writeJSON(tasksPath, rawData, options.projectRoot, tag);
if (generateFiles) {
await generateTaskFiles(tasksPath, path.dirname(tasksPath), {
tag: tag,
projectRoot: projectRoot
});
}
// Note: Task file generation is no longer supported and has been removed
return result;
}

View File

@@ -1,6 +1,4 @@
import path from 'path';
import { log, readJSON, writeJSON } from '../utils.js';
import generateTaskFiles from './generate-task-files.js';
/**
* Remove a subtask from its parent task
@@ -108,11 +106,7 @@ async function removeSubtask(
// Write the updated tasks back to the file with proper context
writeJSON(tasksPath, data, projectRoot, tag);
// Generate task files if requested
if (generateFiles) {
log('info', 'Regenerating task files...');
await generateTaskFiles(tasksPath, path.dirname(tasksPath), context);
}
// Note: Task file generation is no longer supported and has been removed
return convertedTask;
} catch (error) {

View File

@@ -94,7 +94,6 @@ describe('addSubtask function', () => {
const parentTask = writeCallArgs.tasks.find((t) => t.id === 1);
expect(parentTask.subtasks).toHaveLength(1);
expect(parentTask.subtasks[0].title).toBe('New Subtask');
expect(mockGenerateTaskFiles).toHaveBeenCalled();
});
test('should convert an existing task to a subtask', async () => {

View File

@@ -88,11 +88,6 @@ describe('moveTask (unit)', () => {
).rejects.toThrow(/Number of source IDs/);
});
test('batch move calls generateTaskFiles once when flag true', async () => {
await moveTask('tasks.json', '1,2', '3,4', true, { tag: 'master' });
expect(generateTaskFiles).toHaveBeenCalledTimes(1);
});
test('error when tag invalid', async () => {
await expect(
moveTask('tasks.json', '1', '2', false, { tag: 'ghost' })