-
Notifications
You must be signed in to change notification settings - Fork 108
[sql-51] session: handle removed linked account #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[sql-51] session: handle removed linked account #1134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ViktorTigerstrom, 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 an edge case in the KVDB to SQL session migration process. It ensures that sessions which were originally linked to an account, but where that account was subsequently deleted (e.g., via litcli accounts remove
), are still successfully migrated. The changes allow such sessions to be migrated to the SQL store without an associated account, preventing migration failures and maintaining data integrity for these specific scenarios. This improves the robustness of the session migration, particularly when the accounts migration runs before the sessions migration.
Highlights
- Improved Session Migration Robustness: The migration process now gracefully handles sessions linked to accounts that have been subsequently deleted, ensuring these sessions are still migrated to SQL without an associated account.
- Error Handling for Missing Accounts: Modified the
migrateSingleSessionToSQL
function to treatsql.ErrNoRows
for account lookups as a non-fatal error, allowing sessions to migrate without an account link if the linked account is not found. - New
overrideRemovedAccount
Function: Introduced a helper function to reconcile differences between KVDB and SQL sessions during validation, specifically for cases where an account was removed. - Enhanced Test Coverage: Added a new test case to
TestSessionsStoreMigration
to explicitly cover the scenario of migrating a session with a previously deleted linked account, and updatedrandomizedSessions
to simulate account removal during testing.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this 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 correctly handles an edge case during the session migration where a session is linked to an account that has been removed. The changes ensure that the migration proceeds without error by creating the session without the account link, and includes appropriate logging. The test suite has been expanded to cover this scenario. I have a couple of minor suggestions to improve logging and test robustness.
If a user creates a session linked to an account, but later deletes that account using the `litcli accounts remove` command, the KVDB session will still contain the account ID of the removed account. During the KVDB to SQL migration, the accounts migration runs before the sessions migration. Since the deleted account no longer exists, it cannot be migrated. As a result, the migrated SQL session cannot link to the now non-existent account in the SQL store. In such cases, we will migrate the session and not link to any account in the SQL session.
1196e77
to
244509d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In such cases, we will migrate the session and not link to any account in the SQL session.
Are there any safety concerns with removing the account id from the session? I think that any macaroon that carries an unknown account id will not be valid to make requests, rendering the session useless? If that's the case should we just not migrate the session?
I don't think there should be any. I tested this locally with one kvdb session which has a removed account linked, and when sending requests over that session it errors with: Similarly, I tested running with an SQL session, which has I do see your point though, and can see the motivation for just not migrating the session as it's useless once the account has been removed. Potentially instead of dropping the session, we could also just revoke it during the migration. Would be great to get Elle's perspective on this whenever possible. |
This PR fixes a edge case in the sessions migration, which was found during the creation of the actions migration.
If a user creates a session linked to an account, but later deletes that account using the
litcli accounts remove
command, the KVDB session will still contain the account ID of the removed account.During the KVDB to SQL migration, the accounts migration runs before the sessions migration. Since the deleted account no longer exists, it cannot be migrated. As a result, the migrated SQL session cannot link to the now non-existent account in the SQL store.
In such cases, we will migrate the session and not link to any account in the SQL session.