Skip to content

fix: pass context correctly to fixDependenciesCommand to prevent tag data loss#1695

Open
octo-patch wants to merge 1 commit into
eyaltoledano:nextfrom
octo-patch:fix/issue-1636-fix-dependencies-tag-wipe
Open

fix: pass context correctly to fixDependenciesCommand to prevent tag data loss#1695
octo-patch wants to merge 1 commit into
eyaltoledano:nextfrom
octo-patch:fix/issue-1636-fix-dependencies-tag-wipe

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Apr 28, 2026

Fixes #1636

Problem

The fix_dependencies MCP tool (and task-master fix-dependencies CLI) was silently wiping all tags except the resolved one from tasks.json in multi-tag workspaces.

Root cause: fixDependenciesDirect was passing { projectRoot, tag } directly as options, but fixDependenciesCommand destructures these from a nested context key:

// Before (broken):
const options = { projectRoot, tag };
await fixDependenciesCommand(tasksPath, options);

// Inside fixDependenciesCommand:
const { context = {} } = options;
// context = {} — projectRoot and tag are undefined!

With context.projectRoot undefined, writeJSON skipped the tag-merging branch (which requires projectRoot) and wrote only the resolved tag's tasks directly, discarding all other tags.

Solution

Wrap projectRoot and tag under the context key that fixDependenciesCommand expects:

const options = { context: { projectRoot, tag } };
await fixDependenciesCommand(tasksPath, options);

Testing

  • Reproduced the bug with a multi-tag tasks.json — confirmed tags were wiped
  • After fix, all tags are preserved when running fix_dependencies against a specific tag
  • The fix is minimal: one line changed in the MCP direct function wrapper

Note

Medium Risk
Touches the path that reads/writes tasks.json; while the change is a small options-shape fix, mistakes here could still affect task data persistence across tags.

Overview
Ensures the fix_dependencies MCP tool correctly scopes dependency repairs to the requested tag by passing { context: { projectRoot, tag } } into fixDependenciesCommand, preventing other tags in multi-tag tasks.json from being wiped.

Adds a patch changeset documenting the data-loss fix and expected behavior in multi-tag workspaces.

Reviewed by Cursor Bugbot for commit 83cd9df. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue in the fix dependencies tool that incorrectly removed tags from task files, leaving only the master tag. The tool now properly scopes dependency fixes to the intended tag while preserving other tags in multi-tag workspaces.

…data loss (fixes eyaltoledano#1636)

The fixDependenciesDirect MCP wrapper was passing { projectRoot, tag }
directly as options, but fixDependenciesCommand expects these under a
context key: { context: { projectRoot, tag } }.

Without this fix, context.projectRoot was always undefined, causing
writeJSON to skip the tag-merging logic and overwrite tasks.json with
only the resolved tag's tasks — wiping all other tags from the file.

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

🦋 Changeset detected

Latest commit: 83cd9df

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 981e01ad-d4a6-4051-89ee-e7847e047a0e

📥 Commits

Reviewing files that changed from the base of the PR and between 487c3d3 and 83cd9df.

📒 Files selected for processing (2)
  • .changeset/fix-fix-dependencies-tag-wipe.md
  • mcp-server/src/core/direct-functions/fix-dependencies.js

📝 Walkthrough

Walkthrough

This PR fixes a critical bug where the fix_dependencies MCP tool incorrectly wiped all tags except 'master' from tasks.json. The fix restructures how dependency-fixing configuration is passed to fixDependenciesCommand, moving projectRoot and tag into a nested context object to ensure proper tag scoping.

Changes

Cohort / File(s) Summary
Changeset Entry
.changeset/fix-fix-dependencies-tag-wipe.md
Documents patch release for task-master-ai fixing the tag-wiping bug in fix_dependencies tool.
Fix Dependencies Direct Function
mcp-server/src/core/direct-functions/fix-dependencies.js
Restructures parameter passing from top-level { projectRoot, tag } to nested { context: { projectRoot, tag } } to properly scope dependency fixes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary fix: passing context correctly to fixDependenciesCommand to prevent tag data loss, which directly addresses the root cause.
Linked Issues check ✅ Passed The PR directly fixes issue #1636 by wrapping projectRoot and tag under a context key, ensuring writeJSON receives the correct structure to preserve all tags during dependency fixing.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to fixing the tag data loss issue: a one-line fix in fixDependenciesDirect and a corresponding changeset entry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant