Skip to content

fix: API export CRD failure#15788

Merged
pragsty merged 1 commit into4.9.xfrom
APIM-12926_api_export_crd_failure_fix
Mar 30, 2026
Merged

fix: API export CRD failure#15788
pragsty merged 1 commit into4.9.xfrom
APIM-12926_api_export_crd_failure_fix

Conversation

@pragsty
Copy link
Copy Markdown
Contributor

@pragsty pragsty commented Mar 18, 2026

Issue

https://gravitee.atlassian.net/browse/APIM-12926

Description

Area File Change
Repository JdbcUserRepository.java In findByIds(Collection<String> ids), return Collections.emptySet() when ids is null or empty to avoid invalid SQL WHERE u.id IN ().
Service UserCrudServiceImpl.java In findBaseUsersByIds(List<String> userIds), return Set.of() when userIds is null or empty so the repository is not called with an empty list.
Export ApiCRDExportDomainServiceImpl.java In setMembersSourceId(), only set sourceId/source when a user is found (user != null) so group-only members without a user record do not cause NPE.
Screen.Recording.2026-03-18.at.10.20.59.PM.mov

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses a potential failure in the API export CRD process by introducing robust null and empty collection checks across key user-related services. The changes prevent NullPointerExceptions that could arise from invalid or missing user identifiers, thereby improving the stability and reliability of the API management system, particularly during data export operations.

Highlights

  • Defensive Programming: Implemented null and empty collection checks in JdbcUserRepository and UserCrudServiceImpl to prevent NullPointerExceptions when handling user ID collections.
  • API CRD Export Robustness: Added a null check for user objects in ApiCRDExportDomainServiceImpl to ensure safe access to user properties during API CRD export, preventing potential failures.
  • Test Coverage: Enhanced the test suite for UserCrudServiceImpl with new tests to validate behavior when findBaseUsersByIds receives null or empty user ID lists.
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.

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
Copy Markdown
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 addresses a failure in the API export to CRD functionality. The core of the fix is adding a null check in ApiCRDExportDomainServiceImpl to prevent a NullPointerException when a user associated with a membership cannot be found. Additionally, the PR introduces defensive checks in JdbcUserRepository and UserCrudServiceImpl to gracefully handle null or empty collections of user IDs, which is a good practice. Corresponding unit tests have been added to validate this new behavior. The changes are sound and effectively resolve the reported issue. I have one suggestion to refactor the new tests for better conciseness.

@pragsty pragsty force-pushed the APIM-12926_api_export_crd_failure_fix branch from b4151e7 to e73003b Compare March 18, 2026 16:52
@pragsty pragsty changed the title fix: API export CRD failure fix: API export CRD failure(JDBC) Mar 18, 2026
@pragsty pragsty marked this pull request as ready for review March 18, 2026 18:01
@pragsty pragsty requested a review from a team as a code owner March 18, 2026 18:01
@pragsty pragsty changed the title fix: API export CRD failure(JDBC) fix: API export CRD failure Mar 25, 2026
@pragsty pragsty merged commit 45fc1c2 into 4.9.x Mar 30, 2026
49 checks passed
@pragsty pragsty deleted the APIM-12926_api_export_crd_failure_fix branch March 30, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants