Skip to content

Update cache index for Gitlab if existing User Logged in as it creates the actual UserID (integer) - #190

Open
maxkashyap41 wants to merge 1 commit into
redhat-data-and-ai:mainfrom
maxkashyap41:UpdateCacheOnceUserAvailable
Open

Update cache index for Gitlab if existing User Logged in as it creates the actual UserID (integer)#190
maxkashyap41 wants to merge 1 commit into
redhat-data-and-ai:mainfrom
maxkashyap41:UpdateCacheOnceUserAvailable

Conversation

@maxkashyap41

Copy link
Copy Markdown
Contributor

Changes

📝 Description

What changed?

Conditional logic to check the cache index of the existing GitLab user and update the new userID (integer)
If the user is logged in, going ahead in the future in GitLab

Why is this change needed?

This change helps to keep the cache updated for this peculiar GitLab login user factor, where the user is created in GitLab but never logged in, so GitLab didn't generate any user details, such as a numeric userID, which is unique key for fetching user details.

Dependencies

  • N/A

🧪 Testing

Test Coverage

Performance Impact

  • N/A

🚀 Deployment

Deploy Steps

  1. N/A

Prerequisites

  • N/A

Post-Deployment Monitoring

  • N/A

Rollback Plan

  • N/A

⚠️ Breaking Changes

  • This PR contains breaking changes
  • Migration guide provided (if applicable)

Details:

  • N/A

⚙️ Configuration Changes

  • N/A

✅ Developer Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added positive and negative tests that prove my fix is effective or that my feature works
  • Relevant documentation (README, tech specs, etc.) has been added or updated
  • All CI/CD checks are passing

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @maxkashyap41, 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 specific caching inconsistency for GitLab users. Previously, if a GitLab user's ID changed from a temporary identifier (like a username) to a permanent numeric ID after their initial login, the system's cache would not reflect this update. The changes introduce logic to detect this scenario and automatically refresh the cached user ID, ensuring consistency and correct user management.

Highlights

  • GitLab User ID Cache Update: Implemented conditional logic in the group reconciler to detect if a GitLab user's ID has changed in the backend (e.g., from a username string to an integer after their first login). If a change is detected, the cache is updated with the new, actual user ID from GitLab.
  • Improved Logging for GitLab User Fetch: Updated logging messages in the GitLab client to provide more specific information when user details are fetched, including the numeric user ID, and clearer warnings when a user's details are not found because they haven't logged into GitLab yet.
  • New Test Case for GitLab Cache Logic: Added a comprehensive integration test case that simulates a GitLab user login scenario. This test verifies that the system correctly updates a user's cached ID from an initial username string to a numeric ID after the GitLab backend provides the updated information.
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.


A cache holds names, a string so neat, Then GitLab logs, an ID complete. From text to number, swift the change, Our code now handles, in its range.

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.

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

Copy link
Copy Markdown

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 an edge case with GitLab where a user's ID can change from a username to a numeric ID after their first login. The proposed solution is to proactively check for this change during reconciliation and update the cache accordingly. The addition of a comprehensive test case using a mock HTTP server is excellent and ensures the new logic is well-tested.

My main concern is related to performance and concurrency. The new logic introduces a network call within a critical section that is protected by a mutex, which could lead to contention and performance degradation. I've left a detailed comment on this. I also found a couple of minor issues related to code style and test clarity.

Overall, this is a good change that improves the robustness of the GitLab integration, but the concurrency implications should be carefully considered.

Comment thread internal/controller/group_controller.go
Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller_test.go
@maxkashyap41
maxkashyap41 force-pushed the UpdateCacheOnceUserAvailable branch from def41ee to d509c83 Compare February 16, 2026 14:36
Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller.go Outdated
Comment thread internal/controller/group_controller.go
…s the actual UserID (integer)

Signed-off-by: Madhurjya Das <madhurjyakumardas@gmail.com>

Update cache index

Signed-off-by: Madhurjya Das <madhurjyakumardas@gmail.com>

Update cache for gitlab user re-login functionalized

Signed-off-by: Madhurjya Das <madhurjyakumardas@gmail.com>
@maxkashyap41
maxkashyap41 force-pushed the UpdateCacheOnceUserAvailable branch from d509c83 to 84b09ad Compare April 6, 2026 15:57
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