Skip to content

Pass resolvers to JS/Python RPC so PrepareRecipe callbacks can resolve Maven recipes#6742

Merged
jkschneider merged 6 commits intomainfrom
kmccarp/prepare-recipe-fallback
Feb 18, 2026
Merged

Pass resolvers to JS/Python RPC so PrepareRecipe callbacks can resolve Maven recipes#6742
jkschneider merged 6 commits intomainfrom
kmccarp/prepare-recipe-fallback

Conversation

@kmccarp
Copy link
Copy Markdown
Contributor

@kmccarp kmccarp commented Feb 13, 2026

Summary

  • When a JavaScript or Python recipe's preconditions reference Java recipes (e.g. UsesType, UsesMethod), the RPC process calls back to Java via PrepareRecipe. These Java recipes are bundled under the "maven" ecosystem, but JavaScriptRewriteRpc and PythonRewriteRpc were calling the 2-arg RewriteRpc constructor which passes emptyList() for resolvers — causing IllegalStateException("No available resolver for 'maven' ecosystem").
  • Add resolvers field to both JavaScriptRewriteRpc.Builder and PythonRewriteRpc.Builder (defaulting to emptyList() for backward compatibility) and pass through to the 3-arg super constructor.
  • Add defense-in-depth fallback in RewriteRpc.PrepareRecipe handler: if listing.prepare() throws IllegalStateException (resolver missing), fall through to RecipeLoader for recipes already on the classpath.

Test plan

  • Existing RewriteRpcTest passes
  • New test prepareRecipeFallsBackToRecipeLoaderWhenResolverMissing verifies the fallback
  • Companion CLI PR passes resolvers to the builders

When the PrepareRecipe handler finds a recipe in the marketplace but
listing.prepare() throws because no resolver matches the bundle's
ecosystem (e.g., a "maven"-bundled recipe when only a "runtime" resolver
is available), the handler now catches the exception and falls through
to RecipeLoader. This allows recipes that are already on the classpath
to be loaded by class name instead of failing outright.

This fixes recipe runs on Node.js repositories where JS recipes use
preconditions like usesType() or usesMethod() that call back to the
Java side to prepare Java recipes. Without a Maven resolver wired into
the RPC endpoint, these callbacks previously failed with
"No available resolver for 'maven' ecosystem".
Both RPC classes were calling the 2-arg RewriteRpc constructor which
passes emptyList() for resolvers. When a JS/Python recipe's
preconditions reference Java recipes bundled under the "maven"
ecosystem, the PrepareRecipe callback fails with "No available resolver
for 'maven' ecosystem".

Add a resolvers field to both Builders (defaulting to emptyList() for
backward compatibility) and pass them through to the 3-arg super
constructor.
Comment thread rewrite-core/src/main/java/org/openrewrite/rpc/RewriteRpc.java Outdated
@jkschneider jkschneider force-pushed the kmccarp/prepare-recipe-fallback branch from c93359d to 0b9cc6e Compare February 18, 2026 19:23
@jkschneider jkschneider merged commit 81ecb64 into main Feb 18, 2026
1 check passed
@jkschneider jkschneider deleted the kmccarp/prepare-recipe-fallback branch February 18, 2026 19:33
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Feb 18, 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