Skip to content

Conversation

@LeFrosch
Copy link
Collaborator

@LeFrosch LeFrosch commented Feb 9, 2026

Some functions defined in the LocalInvoker can return null under specific circumstances which is not correctly handled in the caller.

This PR updates the implementation to throw a BuildException in these cases, which is already correctly handled in the caller.

Follow up for: #8058

@LeFrosch LeFrosch changed the title Fix localInvoker NPEs Fix LocalInvoker NPEs Feb 9, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @LeFrosch, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors error handling within the LocalInvoker component by transitioning from returning null on failure to throwing BuildExceptions. This change ensures that callers are explicitly informed of operational failures, thereby preventing potential NullPointerExceptions and promoting a more robust and predictable error management pattern across the codebase. The modifications align the method contracts with their actual behavior, enhancing code clarity and reliability.

Highlights

  • Improved Error Handling Contract: The BuildSystem interface's invokeQuery and invokeInfo methods have been updated to explicitly declare that they throw BuildException on failure, removing the previous indication of returning null.
  • Robust LocalInvoker Implementations: The LocalInvoker's invokeQuery and invokeInfo methods now consistently throw BuildException for various failure scenarios, such as ExecutionDeniedException, IOException, or other BuildExceptions, instead of returning null.
  • Removed Redundant Null Check: A null check for the queryResultStream in WildcardTargetExpander has been removed, as the updated invokeQuery method now guarantees to throw an exception on failure, making a null return impossible.
Changelog
  • base/src/com/google/idea/blaze/base/bazel/BuildSystem.java
    • Updated Javadoc for invokeQuery and invokeInfo to reflect that they throw BuildException instead of returning null on failure.
  • base/src/com/google/idea/blaze/base/bazel/LocalInvoker.java
    • Modified invokeQuery and invokeInfo to throw BuildException when an ExecutionDeniedException occurs, replacing the previous behavior of logging and returning null.
    • Refactored exception handling in invokeQuery and invokeInfo to catch IOException and wrap it in a BuildException, and to re-throw existing BuildExceptions, instead of logging and returning null.
    • Removed the @Nullable annotation from invokeInfo to align with the new exception-throwing contract.
  • base/src/com/google/idea/blaze/base/sync/sharding/WildcardTargetExpander.java
    • Removed the verify(queryResultStream != null) check, as invokeQuery is now guaranteed to throw an exception on failure.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses potential NullPointerExceptions in LocalInvoker by modifying invokeQuery and invokeInfo to throw a BuildException on failure instead of returning null. The changes are consistent and correctly propagated to the method's documentation and callers. My review includes a couple of suggestions to simplify the new error handling logic in LocalInvoker.java by removing redundant catch blocks, which would make the code more concise.

Comment on lines +155 to 157
} catch (BuildException e) {
throw e;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This catch block for BuildException is redundant. Since invokeQuery is declared with throws BuildException, any BuildException thrown from the try block will be propagated automatically. You can remove this block to make the code more concise.

Comment on lines +191 to 193
} catch (BuildException e) {
throw e;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This catch block for BuildException is redundant. Since invokeInfo is declared with throws BuildException, any BuildException thrown from the try block will be propagated automatically. You can remove this block to make the code more concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant