Skip to content

Fix local YAML recipe scanning to be recursive#7437

Merged
greg-at-moderne merged 2 commits intoopenrewrite:mainfrom
kdvolder:fix/recursive-yaml-scan
Apr 21, 2026
Merged

Fix local YAML recipe scanning to be recursive#7437
greg-at-moderne merged 2 commits intoopenrewrite:mainfrom
kdvolder:fix/recursive-yaml-scan

Conversation

@kdvolder
Copy link
Copy Markdown
Contributor

@kdvolder kdvolder commented Apr 21, 2026

What's changed?

Fixes a bug introduced in #7338 where ClasspathScanningLoader failed to recursively scan subdirectories for YAML recipes when loading from a local path (e.g., target/classes during mvn test).

Replaced the non-recursive Files.newDirectoryStream with Files.walk in listYamlResourcesFromPath, and added handling for UncheckedIOException which can be thrown by the stream traversal if it encounters unreadable files/directories.

What's your motivation?

We have a large suite of YAML recipes organized into subdirectories (e.g., META-INF/rewrite/framework60/). After upgrading to 8.79.6, all of these recipes started failing to load during local Maven test runs with "Recipe(s) not found" errors.

Anything in particular you'd like reviewers to focus on?

The exception handling around the Files.walk stream. We catch both IOException (for the initial directory open) and UncheckedIOException (for any unreadable subdirectories encountered during traversal) to maintain the previous behavior of gracefully ignoring unreadable files.

Anyone you would like to review specifically?

@sam-snyder (since this relates to the changes in #7338)

Have you considered any alternatives or workarounds?

The only workaround for users currently is to flatten their entire META-INF/rewrite directory structure, which is not ideal for large recipe collections.

Any additional context

A witness test scanYamlInSubdirectory was added to ClasspathScanningLoaderTest to verify recursive YAML loading works correctly.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Copy link
Copy Markdown
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Thanks for the immediate fix!

@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Apr 21, 2026
@greg-at-moderne greg-at-moderne merged commit 25fcfd5 into openrewrite:main Apr 21, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants