Skip to content

fix(link): reject install path aliases - #11785

Merged
jdx merged 1 commit into
jdx:mainfrom
NgoQuocViet2001:fix-link-same-file-alias
Aug 9, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
NgoQuocViet2001:fix-link-same-file-alias

Conversation

@NgoQuocViet2001

@NgoQuocViet2001 NgoQuocViet2001 commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • compare the link source and install target by filesystem identity instead of lexical path
  • prevent mise link --force from deleting a managed install reached through a symlink or junction alias
  • add a regression that verifies an aliased self-link is rejected without removing existing contents

Validation

  • Ran: cargo build
  • Ran: cargo fmt --all -- --check
  • Ran: git diff --check
  • Ran: bash -n e2e/cli/test_link
  • Checked: Windows junction reproduction changed from success with the sentinel deleted to rejection with the sentinel preserved

AI-assisted — Tool: Codex; model: unavailable/unavailable; version: unavailable.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented forced tool linking from deleting managed installations when the source path resolves to the same location.
    • Improved detection of links targeting an existing managed installation, including valid symlink targets.
    • Safely rejects self-referential forced links while preserving the installation and its supporting files.
  • Tests

    • Added an end-to-end regression test covering safe rejection of self-referential forced links.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 452d4df2-45a1-4d78-8529-4b705f718719

📥 Commits

Reviewing files that changed from the base of the PR and between 2f98c3a and 13d1eed.

📒 Files selected for processing (1)
  • src/cli/link.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cli/link.rs

📝 Walkthrough

Walkthrough

The link command now detects self-links by comparing filesystem objects. An end-to-end test verifies that forced linking through a managed-install alias fails without deleting the managed directory or sentinel file.

Changes

Link validation

Layer / File(s) Summary
Filesystem-aware self-link detection
src/cli/link.rs, e2e/cli/test_link
Link::run compares filesystem objects when it checks for self-links. The regression test verifies that managed-install aliases are rejected and preserved.

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

Possibly related PRs

  • jdx/mise#11172: Changes src/cli/link.rs and adds overlapping self-link regression coverage.
  • jdx/mise#11218: Hardens Link::run validation and link-operation tests.
  • jdx/mise#11715: Covers filesystem link handling used to protect managed installations.

Poem

A rabbit checked the link with care,
And found the same install was there.
The force was stopped; the files stayed whole.
The sentinel guarded its little hole.
“Safe links,” twitched the rabbit, “keep control!”

🚥 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 clearly summarizes the main change: rejecting install path aliases in mise link.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR strengthens mise link self-link detection by comparing filesystem identity, preventing forced links through aliases from deleting managed installations.

  • Rejects aliased install paths while preserving legitimate existing links.
  • Adds an end-to-end regression asserting that rejected self-links preserve installation contents.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/cli/link.rs Replaces lexical path comparison with filesystem-identity checking while retaining the existing-link exception; no eligible blocking issue was established.
e2e/cli/test_link Adds a Linux regression covering aliased self-links and verifies that forced rejection preserves the managed installation sentinel.

Reviews (3): Last reviewed commit: "fix(link): reject install path aliases" | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/link.rs`:
- Line 71: Update the self-link guard in the link flow to check
file::is_symlink_to(&target, &path) first and skip the error when the requested
symlink already exists. Only call file::same_file(&path, &target) when target is
not already linked to path, preserving idempotent re-linking.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c5af9570-fb38-4d4d-a0c2-1f00bd6f9037

📥 Commits

Reviewing files that changed from the base of the PR and between b3ebfb9 and 2f98c3a.

📒 Files selected for processing (2)
  • e2e/cli/test_link
  • src/cli/link.rs

Comment thread src/cli/link.rs Resolved
@NgoQuocViet2001
NgoQuocViet2001 force-pushed the fix-link-same-file-alias branch 2 times, most recently from 13d1eed to 855ef06 Compare August 9, 2026 03:20
@jdx
jdx merged commit 7d14107 into jdx:main Aug 9, 2026
30 checks passed
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.

2 participants