Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: NPE thrown when visitArrowFunction encounters empty body #180

Open
DovOps opened this issue Dec 25, 2024 · 5 comments
Open

Bug: NPE thrown when visitArrowFunction encounters empty body #180

DovOps opened this issue Dec 25, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@DovOps
Copy link

DovOps commented Dec 25, 2024

What version of OpenRewrite are you using?

This issue is occuring on the app.moderne.io tenant, when running on the FINOS organization. Several of the repos, when running 'Migrate to Spring Boot 3.3' recipe are erroring due to a JavaScriptVisitor with the same error

org.openrewrite.internal.RecipeRunException: java.lang.NullPointerException
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:290)
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1367)
  org.openrewrite.java.JavaVisitor.lambda$visitContainer$35(JavaVisitor.java:1417)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:243)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:265)
  org.openrewrite.java.JavaVisitor.visitContainer(JavaVisitor.java:1417)
  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:914)
  ...
Caused by java.lang.NullPointerException: null
  java.base/java.util.Objects.requireNonNull(Objects.java:209)
  org.openrewrite.javascript.JavaScriptVisitor.visitArrowFunction(JavaScriptVisitor.java:105)
  org.openrewrite.javascript.tree.JS$ArrowFunction.acceptJavaScript(JS.java:440)
  org.openrewrite.javascript.tree.JS.accept(JS.java:52)
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1367)
  org.openrewrite.java.JavaVisitor.lambda$visitContainer$35(JavaVisitor.java:1417)
  ...

Results : https://app.moderne.io/results/DFdjDhiAr

How are you running OpenRewrite?

This is a simple recipe execution of the rewrite-spring org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 recipe on the app tenant.

What is the smallest, simplest way to reproduce the problem?

Will be looking to reproduce this locally so that the JavaScript file inputs of some of these projects, which look pretty harmless

What did you expect to see?

Expect to see the recipe execute, and worst case ignore some javascript files it finds.

What did you see instead?

image

What is the full stack trace of any errors you encountered?

org.openrewrite.internal.RecipeRunException: java.lang.NullPointerException
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:290)
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1367)
  org.openrewrite.java.JavaVisitor.lambda$visitContainer$35(JavaVisitor.java:1417)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:243)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:265)
  org.openrewrite.java.JavaVisitor.visitContainer(JavaVisitor.java:1417)
  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:914)
  ...
Caused by java.lang.NullPointerException: null
  java.base/java.util.Objects.requireNonNull(Objects.java:209)
  org.openrewrite.javascript.JavaScriptVisitor.visitArrowFunction(JavaScriptVisitor.java:105)
  org.openrewrite.javascript.tree.JS$ArrowFunction.acceptJavaScript(JS.java:440)
  org.openrewrite.javascript.tree.JS.accept(JS.java:52)
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
  org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1367)
  org.openrewrite.java.JavaVisitor.lambda$visitContainer$35(JavaVisitor.java:1417)
  ...

Are you interested in contributing a fix to OpenRewrite?

I hope to look at how this might be fixed.

@DovOps DovOps added the bug Something isn't working label Dec 25, 2024
@DovOps
Copy link
Author

DovOps commented Dec 25, 2024

This affects multiple recipe runs - OWASP Top 10, Java Security Best Practices, and Common Static Analysis, for example.

@OlegDokuka
Copy link
Contributor

Hi, @DovOps!

Thank you for reporting this!
What you have observed is partially expected due to the rapid development of this language integration. We highly appreciate your patience!

We have released a new version OR-JS and CLI that depends on this. The new release has a couple of adjustments. Please re-ingest your projects to ensure you have the JS LSTs built with the most recent version of the js parser.

Let me know if this issue reappears.

Best,
Oleh

@timtebeek timtebeek moved this to Ready to Review in OpenRewrite Dec 28, 2024
@DovOps
Copy link
Author

DovOps commented Dec 29, 2024

Thanks @OlegDokuka - I actually pulled down rewrite-javascript and was looking to recreate this issue with some tests, but could not reproduce it. (Seems that some unit tests have migrated from Java over to native JS based on the gradle configs I was peeking at).

I re-ran things on the app tenant, which errored out with a slightly different NPE around visitFunctionType (instead of arrow function): Looks like this is running rewrite-spring 5.26.0 - and the LST was built with 3.27.8 within the last day.


org.openrewrite.internal.RecipeRunException: java.lang.NullPointerException

  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:290)

  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)

  org.openrewrite.javascript.JavaScriptVisitor.visitTypeInfo(JavaScriptVisitor.java:885)

  org.openrewrite.javascript.tree.JS$TypeInfo.acceptJavaScript(JS.java:3366)

  org.openrewrite.javascript.tree.JS.accept(JS.java:52)

  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)

  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)

  org.openrewrite.java.JavaVisitor.visitVariableDeclarations(JavaVisitor.java:948)

  ...

Caused by java.lang.NullPointerException: null

  java.base/java.util.Objects.requireNonNull(Objects.java:209)

  org.openrewrite.javascript.JavaScriptVisitor.visitFunctionType(JavaScriptVisitor.java:253)

  org.openrewrite.javascript.tree.JS$FunctionType.acceptJavaScript(JS.java:960)

  org.openrewrite.javascript.tree.JS.accept(JS.java:52)

  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)

  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)

  org.openrewrite.javascript.JavaScriptVisitor.visitTypeInfo(JavaScriptVisitor.java:885)

  org.openrewrite.javascript.tree.JS$TypeInfo.acceptJavaScript(JS.java:3366)

  ...

image

image

@OlegDokuka
Copy link
Contributor

Hi, @DovOps!

Also, see that. Trying to reproduce them locally as well. Will keep you updated

thanks,
Oleh

@OlegDokuka
Copy link
Contributor

OlegDokuka commented Dec 30, 2024

Hi, @DovOps!

I appreciate your patience!
We redeployed our app tenant, so now it uses the rewrite-javascript, which includes the required fixes to run recipes normally. After that, I saw that only four repos out of 29 of the FINOS organizations failed with errors. After analysis, it seems that those errors are unrelated to what you initially observed.

image

Please check it from your side as well, and let me know if you encounter anything related to the original problem.

Thanks,
Oleh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Ready to Review
Development

No branches or pull requests

2 participants