fix: handle subtasks in getTask method#1254
Conversation
Fixes issue where 'tm show' command could not find subtasks by their dotted notation ID (e.g., '8.1'). The getTask method now checks if the task ID contains a dot and properly searches within parent task subtasks, returning a Task-like object with the full dotted ID. This mirrors the fix already implemented in updateTaskStatus method for consistent subtask handling across the codebase. Fixes #1253 Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 5c9eb2e The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughgetTask now delegates to storage.loadTask and wraps storage errors in TaskMasterError; file-storage loadTask gained dotted-ID (subtask) resolution that returns composed subtask objects with resolved dependencies and parent context; a changeset documents the tm show subtask fix. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller (e.g., CLI)
participant TS as TaskService.getTask
participant Storage as Storage.loadTask (FileStorage)
C->>TS: getTask(taskId, opts?)
TS->>Storage: loadTask(taskId, tag?)
alt Storage error
Storage-->>TS: throws/Error
TS-->>C: throws TaskMasterError(operation:"loadTask", resource:"task", taskId, tag)
else Storage returns
alt taskId contains "."
Storage-->>TS: returns composed subtask object (dotted id, merged fields, dependencies resolved, parentTask ref)
TS-->>C: return subtask
else
Storage-->>TS: returns task
TS-->>C: return task
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (2).changeset/*.md📄 CodeRabbit inference engine (.cursor/rules/changeset.mdc)
Files:
.changeset/*📄 CodeRabbit inference engine (.cursor/rules/new_features.mdc)
Files:
🧠 Learnings (23)📓 Common learnings📚 Learning: 2025-07-18T17:14:29.399ZApplied to files:
📚 Learning: 2025-07-18T17:14:29.399ZApplied to files:
📚 Learning: 2025-07-18T17:18:17.759ZApplied to files:
📚 Learning: 2025-07-18T17:09:45.690ZApplied to files:
📚 Learning: 2025-07-18T17:09:45.690ZApplied to files:
📚 Learning: 2025-07-18T17:09:40.548ZApplied to files:
📚 Learning: 2025-07-18T17:09:45.690ZApplied to files:
📚 Learning: 2025-07-18T17:14:29.399ZApplied to files:
📚 Learning: 2025-07-18T17:14:29.399ZApplied to files:
📚 Learning: 2025-07-18T17:18:17.759ZApplied to files:
📚 Learning: 2025-09-24T15:12:12.658ZApplied to files:
📚 Learning: 2025-07-18T17:14:29.399ZApplied to files:
📚 Learning: 2025-07-18T17:07:53.100ZApplied to files:
📚 Learning: 2025-08-06T21:14:23.071ZApplied to files:
📚 Learning: 2025-08-11T12:30:23.843ZApplied to files:
📚 Learning: 2025-07-18T17:10:31.810ZApplied to files:
📚 Learning: 2025-07-18T17:07:53.100ZApplied to files:
📚 Learning: 2025-07-18T17:07:53.100ZApplied to files:
📚 Learning: 2025-09-24T15:12:58.855ZApplied to files:
📚 Learning: 2025-07-18T17:10:12.881ZApplied to files:
📚 Learning: 2025-09-25T22:08:11.063ZApplied to files:
📚 Learning: 2025-07-18T17:18:17.759ZApplied to files:
🧬 Code graph analysis (2)packages/tm-core/src/services/task-service.ts (3)
packages/tm-core/src/storage/file-storage/file-storage.ts (2)
🪛 markdownlint-cli2 (0.18.1).changeset/fix-subtask-getTask.md5-5: Trailing spaces (MD009, no-trailing-spaces) 5-5: First line in a file should be a top-level heading (MD041, first-line-heading, first-line-h1) 7-7: Files should end with a single newline character (MD047, single-trailing-newline) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
Comment |
|
@claude don't forget to add your changeset inside .changesets, its task-master-ai patch |
|
Claude finished @Crunchyman-ralph's task —— View job Adding Changeset for Subtask Fix ✅Successfully added the required changeset for the subtask handling fix in getTask method. Tasks:
What was completed:
The changeset follows the repository guidelines by focusing on the user-facing impact (fixing the |
Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
packages/tm-core/src/services/task-service.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/.windsurfrules:0-0
Timestamp: 2025-09-24T15:12:12.658Z
Learning: View task details with task-master show <id> (supports dot notation for subtasks) before implementation
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-complete.md : Create .claude/commands/taskmaster-complete.md with steps to review task, verify, run tests, set status done, and show next task
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Allow numeric subtask IDs to reference other subtasks within the same parent
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:40.548Z
Learning: Applies to scripts/modules/dependency-manager.js : Allow numeric subtask IDs to reference other subtasks within the same parent
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to scripts/modules/utils.js : Implement reusable task finding utilities that support both task and subtask lookups and add context to subtask results.
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1178
File: packages/tm-core/src/auth/config.ts:5-7
Timestamp: 2025-09-02T21:51:27.921Z
Learning: The user Crunchyman-ralph prefers not to use node: scheme imports (e.g., 'node:os', 'node:path') for Node.js core modules and considers suggestions to change bare imports to node: scheme as too nitpicky.
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Allow numeric subtask IDs to reference other subtasks within the same parent
Applied to files:
packages/tm-core/src/services/task-service.ts
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to scripts/modules/utils.js : Implement reusable task finding utilities that support both task and subtask lookups and add context to subtask results.
Applied to files:
packages/tm-core/src/services/task-service.ts
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to scripts/modules/utils.js : Use tagged task system aware functions for task finding and manipulation, handle both task and subtask operations, and validate task IDs before operations.
Applied to files:
packages/tm-core/src/services/task-service.ts
📚 Learning: 2025-07-18T17:14:29.399Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tasks.mdc:0-0
Timestamp: 2025-07-18T17:14:29.399Z
Learning: Applies to scripts/modules/task-manager.js : Use AI to generate detailed subtasks within the current tag context, considering complexity analysis for subtask counts and ensuring proper IDs for newly created subtasks.
Applied to files:
packages/tm-core/src/services/task-service.ts
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Use string IDs with dot notation (e.g., "1.2") for subtask references
Applied to files:
packages/tm-core/src/services/task-service.ts
🪛 GitHub Actions: CI
packages/tm-core/src/services/task-service.ts
[error] 148-156: Biome format check failed: detected formatting issues that require changes (the formatter would have printed updated content). Please run the formatter to fix the code. Command: 'biome format .'
| // Return a Task-like object for the subtask with the full dotted ID | ||
| return { | ||
| id: taskId, | ||
| title: subtask.title || `Subtask ${subtaskId}`, | ||
| description: subtask.description || '', | ||
| status: subtask.status || 'pending', | ||
| priority: subtask.priority || parentTask.priority || 'medium', | ||
| dependencies: subtask.dependencies || [], | ||
| details: subtask.details || '', | ||
| testStrategy: subtask.testStrategy || '', | ||
| subtasks: [], | ||
| tags: parentTask.tags || [], | ||
| assignee: subtask.assignee || parentTask.assignee, | ||
| complexity: subtask.complexity || parentTask.complexity, | ||
| createdAt: parentTask.createdAt, | ||
| updatedAt: parentTask.updatedAt | ||
| }; |
There was a problem hiding this comment.
Ensure subtask dependencies are returned with full dotted IDs
When we surface a subtask via tm show, its dependencies still come back in their raw storage form (e.g., ["2"]). Because consumers expect the canonical dotted notation ("8.2" in this example), the current logic yields ambiguous/incorrect dependency references that can’t be resolved or acted upon. This regresses behavior the rest of the codebase (e.g., getNextTask) already normalizes. Please normalize the dependency IDs before returning the subtask.
Apply this diff to normalize the dependency IDs:
- const subtask = parentTask.subtasks.find((st) => String(st.id) === subtaskId);
+ const subtask = parentTask.subtasks.find((st) => String(st.id) === subtaskId);
if (!subtask) {
return null;
}
+ const toFullSubId = (maybeDotId: string | number): string => {
+ const depId = String(maybeDotId);
+ return depId.includes('.') ? depId : `${parentTask.id}.${depId}`;
+ };
+ const resolvedDependencies =
+ subtask.dependencies?.map((dep) => toFullSubId(dep)) ?? [];
+
// Return a Task-like object for the subtask with the full dotted ID
return {
id: taskId,
title: subtask.title || `Subtask ${subtaskId}`,
description: subtask.description || '',
status: subtask.status || 'pending',
- priority: subtask.priority || parentTask.priority || 'medium',
- dependencies: subtask.dependencies || [],
+ priority: subtask.priority || parentTask.priority || 'medium',
+ dependencies: resolvedDependencies,🤖 Prompt for AI Agents
packages/tm-core/src/services/task-service.ts around lines 160 to 176: subtask
dependency IDs are returned in raw form (e.g., "2") instead of canonical dotted
IDs (e.g., "8.2"); normalize them by mapping subtask.dependencies (or []) to
full dotted IDs before returning—if an entry already contains a dot leave it
as-is, otherwise prefix it with the parent task id (parentTask.id + '.' + dep);
replace the current dependencies assignment in the returned object with this
mapped/normalized array.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
.changeset/fix-subtask-getTask.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
.changeset/*.md
📄 CodeRabbit inference engine (.cursor/rules/changeset.mdc)
.changeset/*.md: When runningnpm run changesetornpx changeset add, provide a concise summary of the changes for theCHANGELOG.mdin imperative mood, typically a single line, and not a detailed Git commit message.
The changeset summary should be user-facing, describing what changed in the released version that is relevant to users or consumers of the package.
Do not use your detailed Git commit message body as the changeset summary.
Files:
.changeset/fix-subtask-getTask.md
.changeset/*
📄 CodeRabbit inference engine (.cursor/rules/new_features.mdc)
Create appropriate changesets for new features, use semantic versioning, include tagged system information in release notes, and document breaking changes if any.
Files:
.changeset/fix-subtask-getTask.md
🧠 Learnings (6)
📓 Common learnings
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1178
File: packages/tm-core/src/auth/config.ts:5-7
Timestamp: 2025-09-02T21:51:27.921Z
Learning: The user Crunchyman-ralph prefers not to use node: scheme imports (e.g., 'node:os', 'node:path') for Node.js core modules and considers suggestions to change bare imports to node: scheme as too nitpicky.
📚 Learning: 2025-09-24T15:12:12.658Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/.windsurfrules:0-0
Timestamp: 2025-09-24T15:12:12.658Z
Learning: View task details with task-master show <id> (supports dot notation for subtasks) before implementation
Applied to files:
.changeset/fix-subtask-getTask.md
📚 Learning: 2025-07-18T17:14:29.399Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/tasks.mdc:0-0
Timestamp: 2025-07-18T17:14:29.399Z
Learning: Applies to scripts/modules/task-manager.js : Use AI to generate detailed subtasks within the current tag context, considering complexity analysis for subtask counts and ensuring proper IDs for newly created subtasks.
Applied to files:
.changeset/fix-subtask-getTask.md
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Allow numeric subtask IDs to reference other subtasks within the same parent
Applied to files:
.changeset/fix-subtask-getTask.md
📚 Learning: 2025-07-18T17:09:45.690Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dependencies.mdc:0-0
Timestamp: 2025-07-18T17:09:45.690Z
Learning: Applies to scripts/modules/dependency-manager.js : Use string IDs with dot notation (e.g., "1.2") for subtask references
Applied to files:
.changeset/fix-subtask-getTask.md
📚 Learning: 2025-07-18T17:10:12.881Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-07-18T17:10:12.881Z
Learning: Use the Taskmaster command set (`task-master` CLI or MCP tools) for all task management operations: listing, expanding, updating, tagging, and status changes.
Applied to files:
.changeset/fix-subtask-getTask.md
🪛 markdownlint-cli2 (0.18.1)
.changeset/fix-subtask-getTask.md
5-5: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
5-5: Files should end with a single newline character
(MD047, single-trailing-newline)
Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Fixes issue where 'tm show' command could not find subtasks by their dotted notation ID (e.g., '8.1').
The getTask method now checks if the task ID contains a dot and properly searches within parent task subtasks, returning a Task-like object with the full dotted ID.
This mirrors the fix already implemented in updateTaskStatus method for consistent subtask handling across the codebase.
Fixes #1253
Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes