Skip to content

Conversation

@feeblefakie
Copy link
Contributor

This is an automated backport of the following:

Please merge this PR after all checks have passed.

@gemini-code-assist
Copy link

Summary of Changes

Hello @feeblefakie, 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 backports a critical fix to address a NullPointerException that could arise when a client is misconfigured with a digital signature in an environment expecting HMAC authentication. The primary solution involves enhancing error handling around secret management by introducing a dedicated MissingSecretException. This ensures that when a secret is not found, an explicit and informative exception is thrown, preventing the NullPointerException and guiding users towards correct configuration.

Highlights

  • New Exception for Missing Secrets: Introduced a new MissingSecretException to specifically handle cases where a required secret cannot be found, providing clearer error messages than a generic NullPointerException.
  • Refactored Secret Lookup Logic: The SecretManager and ScalarSecretRegistry components have been updated to throw the new MissingSecretException when a secret is not found, rather than returning null. This ensures more robust error handling.
  • New Error Code and Status: Added a SECRET_NOT_FOUND error to CommonError.java and a corresponding SECRET_NOT_FOUND status code (415) to StatusCode.java.
  • Integration Test for Misconfiguration: A new integration test has been added to verify that a MissingSecretException is correctly thrown when HMAC authentication is configured, but a client attempts to use a digital signature, addressing the core issue of the NullPointerException.
  • File Removal: The Constants.java file, which contained a single static string KEYS_JSON_NAME, has been removed.
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 backports a fix for a NullPointerException that occurs when a client is misconfigured for digital signatures. The core of the change is to introduce a specific MissingSecretException which is now thrown when a secret is not found, instead of returning null. This makes the error handling more robust and prevents null pointer dereferences. The changes are well-supported by updates to unit tests and a new integration test that validates the fix for the misconfiguration scenario. Overall, this is a solid improvement to the system's error handling and stability.

Comment on lines 59 to 66
public void register(SecretEntry entry) {
SecretEntry existing = registry.lookup(entry.getKey());
if (existing != null) {
try {
registry.lookup(entry.getKey());
throw new DatabaseException(CommonError.SECRET_ALREADY_REGISTERED);
} catch (MissingSecretException e) {
registry.bind(entry);
}
registry.bind(entry);
}

Choose a reason for hiding this comment

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

medium

While this change correctly adapts to the new behavior of registry.lookup (throwing MissingSecretException instead of returning null), the implementation uses exceptions for control flow. This is generally considered an anti-pattern as it can make the code harder to read and can have performance implications.

A more robust and clearer approach would be to implement an atomic registerIfNotExists operation within the SecretRegistry. This could be achieved using a conditional Put operation in ScalarDB (e.g., with PutIfNotExists condition). This would also eliminate a potential race condition between checking for existence and binding the new entry.

As this pattern existed before, this is a suggestion for future improvement rather than a required change for this PR.

@jnmt jnmt merged commit e6fe7a7 into 3.10 Oct 29, 2025
9 checks passed
@jnmt jnmt deleted the 3.10-pull-302 branch October 29, 2025 10:05
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.

2 participants