← Back to Pull requests

[16.0][FIX] fs_storage: check rooted_dir paths by whole components, without os.getcwd() #688

Open
unknown opened this pull request with 324 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 23, 2026 10:29 UTC
Author

Summary

RootedDirFileSystem._join compared paths as text, so it accepted a sibling of its root, such as ../here-backup for the root subdirectory/here. It also called os.getcwd() through make_path_posix, which fails once the working directory is removed (#513). Paths are now normalized as strings and compared by whole components:

- accept if the normalized path starts with the root
+ accept if the normalized path equals the root or starts with the root and a separator

Finishes #522 by @hnavarro-kernet, keeping their commit, as lmignon proposed. Fixes #513.

Review points:

  • Keep the comment lines: kept.

  • The separator may not be /, and the input may be a list or a dict: the rules follow self.sep, and an unknown separator raises ValueError. A / filesystem must also pass the Windows rules, because fsspec turns \ into / in local paths on Windows. Lists and dicts are checked item by item.

  • normpath on remote paths: make_path_posix, the source of os.getcwd(), is no longer called.

  • Separator-aware _join: taken, without PurePath, which changes no POSIX result and adds a trailing \ to UNC roots.
  • Evidence

    The new assertions on 16.0 and with this PR, both on fsspec 2026.9.0. FileNotFoundError means the path got past the check and reached the disk.

                                       before               after
    root "subdirectory/here"
      ls("../here-backup")             FileNotFoundError    PermissionError
      ls("..\here-backup")             FileNotFoundError    PermissionError
      cat([file])                      TypeError            {file: data}
    root "C:\root" on a "\" filesystem
      _join("..\root-backup")          accepted             PermissionError
    

    All 14 fs_storage tests pass.

    Merge Danger

    Door: two-way. Nothing is stored or migrated.

    Blast Radius: narrow.

    Two kinds of paths that used to pass are now refused on every host: paths that climb with backslashes, and any sub path of a root that normalizes to ., such as / on S3, which fsspec reduces to an empty root. 17.0, 18.0, 19.0, and the 20.0 migration #670 have the same check and need forward ports.

    Assisted-by: Claude Opus 5.5
    Assisted-by: Claude Sonnet 5.5
    Assisted-by: Claude Haiku 5.5

    Diff: 324 lines (+243 / -81) across 4 files Reviewer: lmignon Review duration: 36276m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 324 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #688"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.0% (MEDIUM) · Higher = larger blast radius
    42.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%
    Repository