8000 fix: end a symlink loop in the glob walk and print cache errors once by bryan-minimal · Pull Request #3109 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix: end a symlink loop in the glob walk and print cache errors once - #3109

Merged
bryan-minimal merged 3 commits into
mainfrom
fix/subset-walk-loop-cache-error
Nov 13, 2026
Merged

bryan-minimal merged 3 commits into
mainfrom
fix/subset-walk-loop-cache-error

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Nov 6, 2026 •
Copy link
Copy Markdown
Member

Summary

Two pre-existing defects that Norrie (norrietaylor) noted in his approval of #2652. He listed them as "Known and not raised again", and they were kept out of that PR so its approved diff did not change.

The glob walk no longer loops (crates/common/src/lib.rs). common::match_files_for_glob follows symlinked directories. op's subset copy (crates/op/src/subsets.rs) relies on that: a file under usr/lib64 -> lib is copied at both paths. Nothing stopped a link back to a directory the walk was already inside. An output with loop -> . and bin/up -> .. doubled the walk at each level, up to the kernel's 40-link limit. The walk now keeps the device and inode of each directory from the root down to where it is, and does not enter a link that points back to one of them. A link to a directory elsewhere is still followed. As Norrie asked, the lib64/foo paths the subset copy takes today are kept. On main the check cache uses the same walk, so output types valid, missing runtime_deps and the library lookup also stop looping; #2652 moves those to a walk that follows no links.

A cache error prints its cause once (crates/op/src/error.rs, crates/orchestrator/src/error.rs). Cache(#[from] CacheErr) put the error in the message and also returned it as source(), so {:#} printed cache error: not found: not found. StandaloneTestCheck reaches this through check's Error::Other. The message keeps the cause, because most callers print with {}. A hand-written From replaces #[from], and source() is None. Nothing downcasts to CacheErr. #2652 makes the same choice for CacheErr itself.

Not in this PR

The same #[from] shape makes IO and Sandbox in op::Error and orchestrator::Error print their cause twice under {:#}. So do orchestrator's BuildFailed ({1} plus #[source]), both Plan variants and common's FileCacheError. Dropping source() there is not purely cosmetic: minimal/src/main.rs:314, minimal/src/diag/collect.rs:883 and minimald/src/diag.rs:901 walk error chains looking for an io::Error. Each path into those walkers needs checking first, so that is a separate change.

Order with #2652

Both PRs change match_files_for_glob's inner walk, so whichever merges second needs a small rebase there. #2652 is approved, so this PR goes after it.

Testing

  • common: one tree with usr/lib64 -> lib, loop -> . and bin/up -> .. yields exactly bin/ 8000 x, usr/lib/libfoo.so.1 and usr/lib64/libfoo.so.1. The old walk returns far more.
  • op, orchestrator: Cache(NotFound) has no source and prints reading foo: cache error: not found. This covers one made in orchestrator and one converted from op.
  • Prepush on anvil: job 01970 green (PREPUSH: PASSED (8 steps)).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Directory-link traversal now stops when it encounters a loop, while still allowing separate links to the same directory to be searched.
    • Cache errors appear only once in formatted error messages, making diagnostic output clearer.

bryan-minimal and others added 2 commits November 6, 2026 08:30
match_files_for_glob follows symlinked directories, and op's subset copy needs that: a file
under usr/lib64 -> lib is copied at both paths. Nothing stopped a link back to a directory the
walk was inside, so loop -> . with bin/up -> .. doubled the walk at each level up to the kernel's
40-link limit. The walk now keeps the device and inode of each directory from the root down and
does not enter a link to one of them; a link elsewhere is still walked. The test checks both:
the lib64 path is kept and the two-link loop ends with three files. Raised in review on #2652.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
op::Error::Cache and orchestrator::Error::Cache put the CacheErr in their message and, through
#[from], also returned it as source(), so {:#} printed "cache error: not found: not found".
The message keeps the cause for callers that print with {}, a hand-written From replaces
#[from], and source() is None. Nothing downcasts to CacheErr; the variant matches in check and
orchestrator are unchanged. Raised in review on #2652.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai
coderabbitai Bot commented Nov 6, 2026 •
Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The glob walker now prevents directory-link cycles along the current traversal path while still traversing sibling links. The op and orchestrator error types convert cache errors without exposing them through source().

Changes: Glob Directory Traversal

Layer / File(s) Summary
Path-based cycle prevention
crates/common/src/lib.rs
The walker tracks directory device and inode identities on the current path and skips repeated directories. Tests check that sibling links remain traversable and that followed and no-follow walks return the same results for the loop fixture.

Cache Error Reporting

Layer / File(s) Summary
Cache error conversion and source behavior
crates/op/src/error.rs, crates/orchestrator/src/error.rs
Both error types use explicit CacheErr conversions. Tests check that cache errors are not returned by source() and appear once in formatted error chains.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: mitodrummer, evanspearman, 0chroma

Merge Risk: Minimal · up to b818c

The change stops directory-link loops in glob traversal and avoids printing cache errors twice. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title 'fix: end a symlink loop in the glob walk and print cache errors once' follows the Conventional Commit form and matches the two main changes: the glob walk loop fix in crates/common/src/lib.…
Description check Passed The description follows the template. It has a Summary that explains what changes and why, and it links the related PR #2652 in context. It has a Testing section with concrete test expectations and pr…
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.
Full details: Title check

Explanation

The title 'fix: end a symlink loop in the glob walk and print cache errors once' follows the Conventional Commit form and matches the two main changes: the glob walk loop fix in crates/common/src/lib.rs and the cache error source change in op and orchestrator. It is concise and specific. It names both changes, which is slightly broad, but it covers the real content of the changeset.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains what changes and why, and it links the related PR #2652 in context. It has a Testing section with concrete test expectations and prepush evidence (job 01970). The Checklist items are not ticked, and the description does not state whether docs were updated or whether a breaking change applies. The required PR title format is met by the title. The description covers the two fixes in detail and notes what is out of scope.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the directory trail,
It skips old loops and follows sibling mail.
Cache errors keep their message clear,
Their source stays hidden from the chain,
The tests confirm what paths remain,
Then hops away through files again.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: b030336f-b11c-4141-ac92-71d7d1455bf4
Commits

Reviewing files that changed from the base of the PR and between 7770290 and b818c6b.

Files selected for processing: 3

  • crates/common/src/lib.rs
  • crates/op/src/error.rs
  • crates/orchestrator/src/error.rs

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

@bryan-minimal
bryan-minimal marked this pull request as ready for review November 13, 2026 04:48
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 13, 2026 04:48
@minimal-foundry
minimal-foundry Bot commented Nov 13, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at b818c6b20053.

Nothing to do.

Clobber: none seen.

@minimal-foundry minimal-foundry 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.

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 13, 2026
…cache-error

# Conflicts:
#	crates/common/src/lib.rs
@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 692e3a9 Nov 13, 2026
39 checks passed
@bryan-minimal
bryan-minimal deleted the fix/subset-walk-loop-cache-error branch November 13, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0