Conversation
We are putting users to default domain only. That can be created beforehand or its being created on our call. We do not need to adjust our logic according to it. Just log what the status is. Method to create user does not specify that exception is thrown when user does not exist. There can be a variety of problems. Do not assert that in our logs. JIRA: LIGHTY-426 Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Summary of ChangesHello, 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 simplifies the initial setup of users and domains within the AAA module. It refactors the logic to consistently use the default domain for user creation, removing unnecessary conditional checks and specific error handling for existing users. The changes aim to make the initialization process more robust and less prone to misinterpretation of logs. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request simplifies the user and domain creation logic during initialization. The changes to domain creation and logging are an improvement. However, the change to user creation introduces a potential issue. By removing the specific try-catch block for user creation, an expected IDMStoreException (e.g., when the user already exists on a subsequent run) will be logged as an error. My feedback includes a suggestion to restore the try-catch block with a more appropriate log message to handle this case gracefully.
| LOG.debug("Default AAA domain has been created"); | ||
| } | ||
|
|
||
| storeBuilder.createUser(IIDMStore.DEFAULT_DOMAIN, aaaConfiguration.getUsername(), |
There was a problem hiding this comment.
By removing the try-catch block that was previously around the createUser call, any IDMStoreException (for example, if the user already exists) will now be caught by the outer exception handler. This will result in an error being logged (Failed to pre-seed data in store), which is not ideal for an expected condition like the user already existing on subsequent startups. The previous implementation handled this more gracefully, although the log message was a bit too specific as pointed out in the PR description.
To fix this, I suggest re-introducing a try-catch block around the createUser call to handle this specific case and log it at a DEBUG level.
try {
storeBuilder.createUser(IIDMStore.DEFAULT_DOMAIN, aaaConfiguration.getUsername(), aaaConfiguration.getPassword(), true);
LOG.info("Pre-seeded database with custom user '{}'", aaaConfiguration.getUsername());
} catch (final IDMStoreException e) {
LOG.debug("Could not create pre-seeded user, it might already exist. Skipping creation.");
}
We are putting users to default domain only. That can be created beforehand or its being created on our call. We do not need to adjust our logic according to it. Just log what the status is.
Method to create user does not specify that exception is thrown when user does not exist. There can be a variety of problems. Do not assert that in our logs.
JIRA: LIGHTY-426