Skip to content

fix(model-hf): reject rooted POSIX paths in delete on Windows too - #1854

Open
Virgile-pct wants to merge 2 commits into
mainfrom
fix/windows-delete-path-guard
Open

Virgile-pct wants to merge 2 commits into
mainfrom
fix/windows-delete-path-guard

Conversation

@Virgile-pct

@Virgile-pct Virgile-pct commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

On Windows, mesh-llm models delete /tmp/model.gguf answers with a message about model stems and Hugging Face refs instead of saying that filesystem paths are not supported.

Why

parse_delete_model_ref rejects paths with is_absolute() plus a few literal shapes. Windows does not consider a leading / absolute, since that needs a drive letter or a UNC prefix, so a rooted POSIX path passes the guard and falls into the Hugging Face branch.

Measured on Windows 11 by calling resolve_model_identifier directly:

input is_absolute() outcome
/tmp/model.gguf false falls through, "Expected a model stem or Hugging Face ref..."
/home/user/model.gguf false falls through, same
C:\models\model.gguf true rejected as a path
C:/models/model.gguf true rejected as a path
\\server\share\model.gguf true rejected as a path
./model.gguf false rejected as a path
~/model.gguf false rejected as a path

Wrong answer rather than a dangerous one, and only on Windows.

What this changes

A leading / is rejected outright. No model stem or Hugging Face ref starts with one on any platform, and on Unix is_absolute() already covered it, so behaviour there is unchanged.

The test grew from one input to the seven above, minus C:/models/model.gguf, which is deliberately absent: Linux has no reason to treat it as a path, so asserting it would pass on my box and fail in CI.

Measured effect, including a number that needs explaining

Full suite on Windows 11 against main at 3f4f1c35a:

main this branch
passed 3457 3456
failed 17 18

The count went up, so here is the whole of it. One test is fixed, models::delete_tests::resolve_model_identifier_rejects_filesystem_paths, which is the one this branch targets. Two others failed that do not fail on main:

  • runtime::config_state::tests::sync::config_sync_state_apply_preserves_additive_defaults_sections
  • runtime::config_state::tests::sync::config_sync_state_apply_preserves_nested_sections_and_updates_hash

Both pass 5 runs out of 5 in isolation. runtime::config_state never calls resolve_model_identifier or parse_delete_model_ref, and this branch touches one guard in model-hf plus its test. This box produces one to three intermittent failures per full run, varying between runs, and today alone it surfaced three different ones across unrelated modules.

I would rather show you the raw number with that explanation than a tidier one.

Gates

  • cargo test -p model-hf: 47 passed, 0 failed.
  • cargo test -p mesh-llm-host-runtime: as above.
  • cargo fmt --all --check: clean.
  • cargo clippy -p model-hf -p mesh-llm-host-runtime --all-targets: 8 lints, complete sorted set identical to main.
  • cargo run -p xtask -- repo-consistency no-console-print: passed.
  • scripts/check-env-mutation-contract.py and python -m unittest scripts.tests.test_env_mutation_contract: passed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved model reference validation to consistently reject filesystem paths across platforms.
    • Added coverage for Unix, Windows, network, relative, and home-directory path formats.
    • Error messages now identify the invalid path that was provided.

`parse_delete_model_ref` rejects filesystem paths by testing `is_absolute()`
plus a few literal shapes. Windows does not consider a leading `/` absolute,
since that needs a drive letter or a UNC prefix, so a rooted POSIX path slipped
through the guard there and fell into the Hugging Face branch instead.

Measured on Windows 11 by calling `resolve_model_identifier` directly:

    /tmp/model.gguf            is_absolute=false  -> "Expected a model stem or
                                                     Hugging Face ref..."
    /home/user/model.gguf      is_absolute=false  -> same
    C:\models\model.gguf       is_absolute=true   -> rejected as a path
    C:/models/model.gguf       is_absolute=true   -> rejected as a path
    \\server\share\model.gguf  is_absolute=true   -> rejected as a path
    ./model.gguf               is_absolute=false  -> rejected as a path
    ~/model.gguf               is_absolute=false  -> rejected as a path

So `mesh-llm models delete /tmp/model.gguf` answered with a message about model
stems and Hugging Face refs rather than saying that paths are not supported.
Wrong answer, not a dangerous one, and only on Windows.

A leading `/` is now rejected outright. No model stem or Hugging Face ref starts
with one on any platform, and on Unix `is_absolute()` already covered it, so
behaviour there is unchanged.

The test grew from one input to seven, covering the rooted POSIX, Windows drive,
UNC, relative and tilde shapes. `C:/models/model.gguf` is deliberately absent:
Linux has no reason to treat it as a path, and asserting it would pass here and
fail in CI.
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 971661bf-d556-4a39-9604-ae74cbf4eebe

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4f1c3 and b1fa3cb.

📒 Files selected for processing (2)
  • crates/mesh-llm-host-runtime/src/models/delete_tests.rs
  • crates/model-hf/src/store/delete.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The delete model reference parser now rejects POSIX-rooted inputs in addition to absolute paths. Tests cover Unix, Windows, UNC, relative, and tilde-based filesystem path shapes.

Changes

Delete Path Validation

Layer / File(s) Summary
Path rejection and validation
crates/model-hf/src/store/delete.rs, crates/mesh-llm-host-runtime/src/models/delete_tests.rs
parse_delete_model_ref rejects inputs beginning with /. The test checks seven filesystem path shapes against the filesystem-path error and reports the failing input.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: ndizazzo

Merge Risk: ⚪ Minimal · up to fa337

Delete-reference validation now rejects the additional rooted path forms, with matching coverage; no merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting rooted POSIX paths in model deletion on Windows.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-delete-path-guard

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.

@i386 i386 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the synchronized exact head. The Windows deletion guard covers leading-slash rooted paths and preserves valid relative paths; model-hf and full host-runtime package suites pass locally.

@i386
i386 enabled auto-merge (squash) September 15, 2026 05:38
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