Skip to content

fix: match withheld targets without a partial fix plan - #1646

Merged
sonukapoor merged 1 commit into
mainfrom
bugfix/issue-1643-withheld-plan-lookup
Nov 13, 2026
Merged

sonukapoor merged 1 commit into
mainfrom
bugfix/issue-1643-withheld-plan-lookup

Conversation

@sonukapoor

Copy link
Copy Markdown
Collaborator

The shell-safety withholding added in v1.41.2 found which finding a withheld target belonged to by calling findFixTargetForFinding with a stand-in plan cast from { targets }. It worked only because the lookup reads nothing but targets. Any change to the lookup that reads another plan field crashes scans where a command is withheld, which is what happens when #1588 meets main (Cannot read properties of undefined (reading 'some') on a multi-folder project with an R&D subfolder).

The matching now lives in a function that takes a list of targets. findFixTargetForFinding delegates to it, and the withholding step calls it directly, so the cast is gone. No behaviour change; the full suite passes unchanged.

Closes #1643

The shell-safety withholding called findFixTargetForFinding with a stand-in
plan cast from { targets }, so any lookup change that reads another plan field
crashed scans with a withheld command. Matching now lives in a function that
takes a target list; the plan lookup delegates to it and the withholding step
calls it directly.

Closes #1643
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Refactor
    • Updated internal matching for shell-unsafe fix targets. No user-facing changes were reported.

Shell-unsafe target withholding now matches findings against withheld targets directly. The plan-based lookup delegates its matching logic to a helper that accepts a target list.

Changes: Withheld target matching

Layer / File(s) Summary
Target-list lookup
src/remediation/fix-commands.ts
findFixTargetForFinding delegates to findFixTargetAmong. Shell-unsafe withholding uses the helper with withheld targets instead of constructing a temporary plan. The matching behavior is unchanged.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 4a714

This is an internal refactor of target matching with no intended behavior change. No merge-blocking risk was identified.

Pre-merge checks: Passed 7

Check name Status Explanation
Title check Passed The title uses the required "fix: " prefix, lowercase after the colon, no trailing period. It names the main change: withheld targets are now matched without building a partial fix plan. It is specifi…
Description check Passed The description explains the problem and the change. It covers the v1.41.2 stand-in plan cast, the crash that happens when the lookup reads another plan field, and the new list-based matching function…
Linked Issues check Passed I checked #1643 against the diff of src/remediation/fix-commands.ts between the merge base and the reviewed head. The three requirements are met.

1. Target matching takes a list of targets. The diff …
Out of Scope Changes check Passed All changes in the diff serve #1643. The diff touches one file, src/remediation/fix-commands.ts. It adds the findFixTargetAmong helper, makes findFixTargetForFinding a thin delegate, and changes t…
Linked Issue Passed I passed this check. The pull request body ends with "Closes #1643", which uses the keyword Closes followed by an issue number, as the check requires. The linked issue is #1643, "Shell-unsafe withhold…
Closes Keyword Matches Scope Passed I reviewed the PR body. It uses "Closes #1643", so this check applies. Issue #1643 asks for three items under "Done when", plus a no-behavior-change condition: 1. The target-matching logic lives in a …
No New Runtime Dependency Passed This check fails only when package.json gains a runtime dependency. The pre-merge range changes one file: M src/remediation/fix-commands.ts. package.json and package-lock.json are not in the diff, s…
Full details: Title check

Explanation

The title uses the required "fix: " prefix, lowercase after the colon, no trailing period. It names the main change: withheld targets are now matched without building a partial fix plan. It is specific to the changeset.

Full details: Description check

Explanation

The description explains the problem and the change. It covers the v1.41.2 stand-in plan cast, the crash that happens when the lookup reads another plan field, and the new list-based matching function. It states there is no behavior change and links issue #1643. It does not follow the template's exact heading "What changed and why", but it gives the same information. The "Closes #1643" line follows the template's closing reference.

Full details: Linked Issues check

Explanation

I checked #1643 against the diff of src/remediation/fix-commands.ts between the merge base and the reviewed head. The three requirements are met.

  1. Target matching takes a list of targets. The diff adds findFixTargetAmong(targets: SuggestedFixTarget[], finding: Finding). Its targets.find(...) replaces the former plan.targets.find(...).
  2. findFixTargetForFinding delegates to it. The public function now returns findFixTargetAmong(plan.targets, finding).
  3. The withholding step calls the helper directly. withholdShellUnsafeTargets now builds const withheldTargets = [...withheld.keys()] and calls findFixTargetAmong(withheldTargets, finding). The { targets } as SuggestedFixCommandPlan cast is removed.

The matching logic is unchanged apart from reading targets instead of plan.targets, so no behaviour change is expected. I did not run the test suite. The claim that the suite passes unchanged rests on the author's report and on the absence of test edits in this diff. The diff hunk does not show the rest of the helper body. The issue states that the lookup reads only targets, and the diff is consistent with that.

Full details: Out of Scope Changes check

Explanation

All changes in the diff serve #1643. The diff touches one file, src/remediation/fix-commands.ts. It adds the findFixTargetAmong helper, makes findFixTargetForFinding a thin delegate, and changes the withholding call site to use the helper with a plain array. No unrelated logic, formatting, or public declarations change. The change summary reports no alterations to exported declarations. I did not inspect the full PR file list, so I rely on the summary for the absence of other touched files.

Full details: Linked Issue

Explanation

I passed this check. The pull request body ends with "Closes #1643", which uses the keyword Closes followed by an issue number, as the check requires. The linked issue is #1643, "Shell-unsafe withholding passes a partial fix plan to the target lookup." I did not need repository tools to decide this. The check only tests whether the PR body references an issue, and the supplied PR description shows that reference. I did not assess whether the code change is correct.

Full details: Closes Keyword Matches Scope

Explanation

I reviewed the PR body. It uses "Closes #1643", so this check applies. Issue #1643 asks for three items under "Done when", plus a no-behavior-change condition: 1. The target-matching logic lives in a function that takes a list of targets, and findFixTargetForFinding delegates to it. Delivered. The diff adds findFixTargetAmong(targets, finding), which holds the matching logic. findFixTargetForFinding now returns findFixTargetAmong(plan.targets, finding). 2. The withholding step uses that function directly, so no partial plan object or cast remains. Delivered. withholdShellUnsafeTargets now builds withheldTargets as a plain array and calls findFixTargetAmong(withheldTargets, finding). The { targets } as SuggestedFixCommandPlan cast is removed. 3. No behavior change. The helper reads only the target list and the finding, and the early return on parentUpgradeBlockers does not depend on the plan. The change is a pure refactor of the lookup's inputs. 4. The full suite passes unchanged. This is the author's claim. I could not run the build or test suite in this sandbox, so I did not verify it independently. It is a verification result, not unbuilt code, so it does not block this check. The diff touches one file, src/remediation/fix-commands.ts, and delivers every code item the issue lists. Merging with "Closes #1643" will not auto-close the issue with work still unbuilt.

Full details: No New Runtime Dependency

Explanation

This check fails only when package.json gains a runtime dependency. The pre-merge range changes one file: M src/remediation/fix-commands.ts. package.json and package-lock.json are not in the diff, so no entry was added to "dependencies" or "optionalDependencies", and no package moved from devDependencies. The current head package.json lists five runtime dependencies (better-sqlite3, fflate, semver, yaml, yarn-lockfile). It has no optionalDependencies block. The PR changes only the internal target-matching code in fix-commands.ts, so the check is satisfied. Tone note: as requested, this is written as a maintainer would write it. The PR does not add a runtime package. It only refactors the target lookup so the withholding step passes a list of targets, not a cast partial plan. Users see no new install footprint from this change.

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

Recent review info

Automatic approval policy

Commit: 4a714a3462be.

Setting Effective value Source
Automatic approvals Enabled Global configuration
Merge risk Moderate Global configuration
Security risk Not set Global configuration

No overrides matched. The global limits apply.

Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3d7af2c and 4a714a3.

Files selected for processing: 1

  • src/remediation/fix-commands.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@sonukapoor
sonukapoor merged commit 9cc993e into main Nov 13, 2026
12 checks passed
@sonukapoor
sonukapoor deleted the bugfix/issue-1643-withheld-plan-lookup branch November 13, 2026 16:24
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.

Shell-unsafe withholding passes a partial fix plan to the target lookup

1 participant