Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-update-task-research-variant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---

Fix `update-task` and `update-subtask` crashing with `Cannot read properties of undefined (reading 'replace')` when the `--research` flag is used. Both commands were requesting a non-existent `research` prompt variant; they now correctly use the `default` variant, which already handles research mode via template conditionals.
2 changes: 1 addition & 1 deletion scripts/modules/task-manager/update-subtask-by-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async function updateSubtaskById(
projectRoot: projectRoot
};

const variantKey = useResearch ? 'research' : 'default';
const variantKey = 'default';
const { systemPrompt, userPrompt } = await promptManager.loadPrompt(
'update-subtask',
promptParams,
Expand Down
6 changes: 1 addition & 5 deletions scripts/modules/task-manager/update-task-by-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,7 @@ async function updateTaskById(
projectRoot: projectRoot
};

const variantKey = appendMode
? 'append'
: useResearch
? 'research'
: 'default';
const variantKey = appendMode ? 'append' : 'default';

report(
'info',
Expand Down
55 changes: 55 additions & 0 deletions tests/unit/scripts/modules/task-manager/update-task-by-id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,61 @@ describe('Prompt Manager Integration', () => {
const promptManagerInstance = getPromptManager.mock.results[0].value;
expect(promptManagerInstance.loadPrompt).toHaveBeenCalled();
});

test('should use "default" variant when useResearch is true (regression: #1689)', async () => {
// Arrange
fs.existsSync.mockReturnValue(true);
readJSON.mockReturnValue({
tag: 'master',
tasks: [
{
id: 1,
title: 'Task',
description: 'Description',
status: 'pending',
dependencies: [],
priority: 'medium',
details: 'Details',
testStrategy: 'Test strategy',
subtasks: []
}
]
});

generateObjectService.mockResolvedValue({
mainResult: {
task: {
id: 1,
title: 'Updated Task',
description: 'Updated description',
status: 'pending',
dependencies: [],
priority: 'medium',
details: 'Updated details',
testStrategy: 'Updated test strategy',
subtasks: []
}
},
telemetryData: {}
});

// Act - pass useResearch: true as 4th argument
await updateTaskById(
'tasks/tasks.json',
1,
'Update this task',
true, // useResearch
{ tag: 'master', projectRoot: '/mock/project' },
'json'
);

// Assert - loadPrompt must be called with 'default', not 'research'
// (the update-task template has no 'research' variant; useResearch is handled
// via {{#if useResearch}} conditionals inside the 'default' variant)
const promptManagerInstance = getPromptManager.mock.results[0].value;
const loadPromptCall = promptManagerInstance.loadPrompt.mock.calls[0];
expect(loadPromptCall[2]).toBe('default');
});
});

describe('Context Gathering Integration', () => {
Expand Down
Loading