openrewrite / openrewrite/rewrite
Recognize recipes containing themself
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with DeclarativeRecipe.initialize, especially the locations shown at lines 91, 96, and 106 in the stack trace, and trace how nested recipes are initialized. Use the self-referencing YAML example to verify that initialization detects the cycle and reports a clear error instead of producing a StackOverflowError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100