Skip to content

Fix nested file search when starter path is a file#7665

Open
modernzju wants to merge 1 commit into
FuelLabs:masterfrom
modernzju:master
Open

Fix nested file search when starter path is a file#7665
modernzju wants to merge 1 commit into
FuelLabs:masterfrom
modernzju:master

Conversation

@modernzju

Copy link
Copy Markdown

Description

This fixes find_nested_dir_with_file so that, when the provided starter path is a file, the WalkDir traversal starts from the file's parent directory.

The function already computed starter_dir for this case, but still passed the original starter_path to WalkDir. As a result, nested files such as Forc.toml could be missed when the search started from a manifest file rather than a directory.

A targeted unit test was added to cover searching from a root Forc.toml file while skipping that root file and finding a nested Forc.toml.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

Signed-off-by: modernzju <modernzju@outlook.com>
@modernzju modernzju requested a review from a team as a code owner June 20, 2026 16:46
@fuel-cla-bot

fuel-cla-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @modernzju to sign the Fuel Labs Contributor License Agreement.

@cursor

cursor Bot commented Jun 20, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Single-line behavior fix in a path helper with a targeted unit test; no auth, security, or broad API changes.

Overview
find_nested_dir_with_file now passes starter_dir into WalkDir::new instead of the raw starter_path. When the starter is a file, the walk already derived the parent directory but still rooted the traversal on the file path, so nested matches (e.g. a child Forc.toml) could be skipped while the root file was ignored.

A unit test covers starting from a root manifest file, skipping that file, and finding a nested Forc.toml in a temp tree.

Reviewed by Cursor Bugbot for commit a921d53. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant