You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: match withheld targets without a partial fix plan - #1646
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.
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
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.
findFixTargetForFinding delegates to findFixTargetAmong. Shell-unsafe withholding uses the helper with withheld targets instead of constructing a temporary plan. The matching behavior is unchanged.
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: 7
Check name
Status
Explanation
Title check
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
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
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
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
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
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
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.
Target matching takes a list of targets. The diff adds findFixTargetAmong(targets: SuggestedFixTarget[], finding: Finding). Its targets.find(...) replaces the former plan.targets.find(...).
findFixTargetForFinding delegates to it. The public function now returns findFixTargetAmong(plan.targets, finding).
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shell-safety withholding added in v1.41.2 found which finding a withheld target belonged to by calling
findFixTargetForFindingwith a stand-in plan cast from{ targets }. It worked only because the lookup reads nothing buttargets. 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 anR&Dsubfolder).The matching now lives in a function that takes a list of targets.
findFixTargetForFindingdelegates to it, and the withholding step calls it directly, so the cast is gone. No behaviour change; the full suite passes unchanged.Closes #1643