rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

Recognize recipes containing themself

Open Bananeweizen opened this issue 1 year ago • 1 comments

What problem are you trying to solve?

I accidentally included a recipe in itself. The StackoverflowError should be avoided, and a clear error message should be presented.

Describe the solution you'd like

Check any nested recipe to not be in the "already seen" set at the beginning of the initialization request.

Additional context

---
type: specs.openrewrite.org/v1beta/recipe
name: myrecipes
displayName: My recipes
description: Accidentially contains itself
recipeList:
  - myrecipes
java.lang.StackOverflowError
    at org.openrewrite.config.DeclarativeRecipe.initialize (DeclarativeRecipe.java:96)
    at org.openrewrite.config.DeclarativeRecipe.initialize (DeclarativeRecipe.java:91)
    at org.openrewrite.config.DeclarativeRecipe.initialize (DeclarativeRecipe.java:106)
    at org.openrewrite.config.DeclarativeRecipe.initialize (DeclarativeRecipe.java:91)

Are you interested in contributing this feature to OpenRewrite?

Yes.

Bananeweizen avatar May 23 '24 14:05 Bananeweizen

Hah, not the first time seeing that indeed; would be good to have that handled explicitly; thanks for offering to help!

timtebeek avatar May 23 '24 15:05 timtebeek