Skip to content

Conversation

@komamitsu
Copy link
Contributor

Description

In the current implementation, AuthAdmin has getRoles(), but doesn't have getRole(roleName). Therefore, dependent libraries need to retrieve all the roles by using getRoles() and then filter them by the target role name. This PR introduces getRole(roleName) method for address the inefficient execution.

Related issues and/or PRs

Changes made

  • Added AuthAdmin.getRole(roleName)
  • Added DecoratedDistributedTransactionAdmin.getRole(roleName)

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

The added interface method has a default implementation, so it shouldn't cause any compile error in the dependent libraries.

Release notes

Added AuthAdmin.getRole(roleName).

Copilot AI review requested due to automatic review settings December 2, 2025 08:54
@komamitsu komamitsu self-assigned this Dec 2, 2025
@komamitsu komamitsu added the enhancement New feature or request label Dec 2, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @komamitsu, 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 enhances the AuthAdmin interface by introducing a new getRole(roleName) method. This change addresses an inefficiency where dependent libraries previously had to retrieve all roles and then filter them to find a specific one. By providing a direct method, the system can now fetch individual roles more efficiently, streamlining role-based access control operations.

Highlights

  • New API Method: Introduced AuthAdmin.getRole(roleName) to allow direct retrieval of a specific role by name, improving efficiency over fetching all roles and filtering.
  • Implementation: Added the corresponding implementation for getRole(roleName) in DecoratedDistributedTransactionAdmin, which delegates the call to the underlying admin instance.
  • Backward Compatibility: The new interface method includes a default implementation, ensuring no compile errors for dependent libraries.
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.

@komamitsu
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@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 introduces a new getRole(roleName) method to the AuthAdmin interface, providing a more efficient way to retrieve a single role by its name instead of fetching all roles. The change is well-motivated and the implementation in DecoratedDistributedTransactionAdmin correctly delegates the call. My only feedback is to improve the Javadoc for the new interface method to make it more complete and accurate for future users of the API.

Copy link
Contributor

@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 introduces a getRole(roleName) method to the AuthAdmin interface, providing a more efficient way to retrieve a specific role compared to fetching all roles and filtering. The change is well-implemented in DecoratedDistributedTransactionAdmin by delegating the call. My feedback focuses on improving the Javadoc for the new method to ensure it is complete and accurate.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new getRole(roleName) method to the AuthAdmin interface and its decorator implementation to enable more efficient role retrieval in RBAC operations. Previously, clients had to fetch all roles via getRoles() and filter locally, which was inefficient.

Key Changes

  • Added AuthAdmin.getRole(String roleName) interface method with default implementation that throws UnsupportedOperationException
  • Implemented getRole(String roleName) in DecoratedDistributedTransactionAdmin to delegate to the underlying admin instance

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
core/src/main/java/com/scalar/db/api/AuthAdmin.java Adds new getRole(roleName) interface method with default implementation for retrieving a single role
core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionAdmin.java Implements the new getRole(roleName) method by delegating to the wrapped admin instance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@feeblefakie feeblefakie enabled auto-merge (squash) December 4, 2025 00:52
@feeblefakie feeblefakie merged commit f017785 into master Dec 4, 2025
71 of 72 checks passed
@feeblefakie feeblefakie deleted the rbac-get-role branch December 4, 2025 00:59
feeblefakie added a commit that referenced this pull request Dec 4, 2025
feeblefakie added a commit that referenced this pull request Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants