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

NPE Errors on "Navigate > File..." #6948

Closed
andponlin-canva opened this issue Oct 31, 2024 · 2 comments
Closed

NPE Errors on "Navigate > File..." #6948

andponlin-canva opened this issue Oct 31, 2024 · 2 comments
Assignees
Labels
awaiting-maintainer Awaiting review from Bazel team on issues product: IntelliJ IntelliJ plugin type: bug

Comments

@andponlin-canva
Copy link
Contributor

Description of the bug:

An engineer on team is running the beta of the plugin 2024.10.22.0.2 on Intelli-J 2024.2.4 and is finding that the code in BlazeModuleRendererFactory#getModuleTextWithIcon is producing NPEs when they use the "Navigate > File..." function;

java.lang.NullPointerException: Cannot invoke "com.intellij.openapi.vfs.VirtualFile.getPath()" because "file" is null
	at com.google.idea.blaze.base.model.primitives.WorkspaceRoot.workspacePathFor(WorkspaceRoot.java:96)
	at com.google.idea.blaze.base.model.primitives.WorkspaceRoot.relativize(WorkspaceRoot.java:100)
	at com.google.idea.blaze.base.ui.BlazeModuleRendererFactory.getModuleTextWithIcon(BlazeModuleRendererFactory.java:45)
...

The value which is unexpectedly null is sourceRoot here;

var sourceRoot = index.getSourceRootForFile(file);

I have added the following lines below this one in the source;

if (sourceRoot == null) {
    String msgTemplate = "was not able to get the source root from the project index " +
        "for the file [%s] from psi-element [%s]";
    logger.warn(String.format(msgTemplate, file, psiElement));
    return null;
}

I am unable to share the output, but the PSI elements and corresponding files are part of the project's regular files and map to sensible looking VirtualFile objects. They have tried to re-index but the problem persists. Other engineers do not see this problem.

The null-check code above will simply mask the real problem so may not be desirable, but may be better than no fix as it otherwise fails the impacted UI function entirely.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

It has not been possible to reproduce the bug.

Which Intellij IDE are you using? Please provide the specific version.

Intelli-J 2024.2.4

What programming languages and tools are you using? Please provide specific versions.

No response

What Bazel plugin version are you using?

2024.10.22.0.2

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@tpasternak
Copy link
Contributor

fixed by #6960

@github-project-automation github-project-automation bot moved this from Untriaged to Done in Bazel IntelliJ Plugin Nov 5, 2024
@andponlin-canva
Copy link
Contributor Author

andponlin-canva commented Nov 5, 2024

Thank you @tpasternak !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-maintainer Awaiting review from Bazel team on issues product: IntelliJ IntelliJ plugin type: bug
Projects
Development

No branches or pull requests

5 participants