-
Notifications
You must be signed in to change notification settings - Fork 456
Feature/session service well known error #353
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: main
Are you sure you want to change the base?
Feature/session service well known error #353
Conversation
Summary of ChangesHello @FamALouiz, 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 focuses on enhancing the session service's error handling by introducing standardized, well-known error types. It centralizes common error definitions and updates both the database and in-memory session implementations to consistently utilize these new error types, particularly Highlights
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.
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 does a good job of standardizing error handling by introducing ErrSessionNotFound and refactoring tests with a helper function. The changes to the database service implementation are correct. However, there are several critical issues that need to be addressed. The in-memory service's Delete method was not updated to return the new error, which undermines the goal of consistent behavior. Additionally, multiple tests that were updated to expect ErrSessionNotFound only check for the presence of an error, not the specific error type, which could hide bugs. There are also some minor inconsistencies in test naming and error message formatting that should be fixed.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
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 does a great job of standardizing error handling by introducing ErrSessionNotFound and applying it consistently across both the database and in-memory implementations of the session service. This significantly improves the predictability and robustness of the service. The test updates are thorough and correctly validate the new error behavior.
I have a few suggestions for improvement:
- One comment in
session/database/service.gohas become outdated due to the changes and should be updated to avoid confusion. - The error handling logic in the tests within
session/inmemory_test.gois slightly inconsistent with the patterns insession/database/service_test.go. Aligning these would improve maintainability. The PR description mentions acheckTestError()helper function, which would be an excellent way to enforce this consistency.
Overall, these are solid improvements that enhance the quality of the codebase.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
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 effectively standardizes error handling for the session service by introducing ErrSessionNotFound and ensuring its consistent use in both the database and in-memory implementations. This is a great improvement for the robustness and predictability of the API. The refactoring to rename variables that shadowed the session package name and fixing test names also improves code clarity. The tests have been properly updated to assert the new error behavior. My main suggestion is to reduce code duplication in the test files, which would further improve maintainability.
|
I'll take a look at the requested changes and get this PR going. Thanks @kdroste-google |
|
/gemini review |
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 effectively standardizes error handling by introducing well-known errors, which significantly improves consistency between the database and in-memory session service implementations. The alignment of the Delete operation's behavior is a notable improvement. Additionally, the refactoring of tests to use a helper function for error checking cleans up the test code nicely. I have one suggestion regarding code duplication in the test helpers.
8839c34 to
e74b07c
Compare
|
/gemini review |
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 introduces standardized error handling for the session service by creating a well-known ErrSessionNotFound error. The changes are excellent, updating both the database and in-memory implementations to use this error consistently, which improves the robustness and predictability of the service. The alignment of behavior for Delete operations on non-existent sessions is a particularly valuable consistency fix. Additionally, the new AssertTestError test helper effectively simplifies and cleans up the test code. The code quality is high, and the changes are well-tested. I have no further recommendations as no issues of medium or higher severity were found.
Session Service: Well-Known Error Handling
Resolves #85
This PR introduces standardized error handling for the session service by creating well-known errors and updating both in-memory and database implementations to use them consistently.
Changes Made
1. Created Well-Known Errors (
session/errors.go)ErrSessionNotFound- returned when a session cannot be foundErrStateKeyNotExist- returned when a state key doesn't exist2. Updated Session Service Implementations
Database Service (
session/database/service.go)Get()to returnErrSessionNotFoundwhengorm.ErrRecordNotFoundis encounteredDelete()to returnErrSessionNotFoundwhen no rows are affected (session doesn't exist)In-Memory Service (
session/inmemory.go)Get()to returnErrSessionNotFoundinstead of generic errorAppendEvent()to returnErrSessionNotFoundwhen session is not found3. Test Improvements
Added Test Helper Function
checkTestError()helper to eliminate code duplication across test filest.Fatalf()for immediate test termination on error, ensuring consistent error handlingservice_test.goandinmemory_test.goBreaking Change Note
This changes the error behavior for
Delete()operations - previously, deleting a non-existent session returned no error, but now returnsErrSessionNotFound. This aligns the behavior between database and in-memory implementations.