refactor: Enforce ServerCallContext in all TaskStore operations#882
refactor: Enforce ServerCallContext in all TaskStore operations#882sokoliva wants to merge 3 commits intoa2aproject:1.0-devfrom
Conversation
Summary of ChangesHello, 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 refactors the 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. Footnotes
|
🧪 Code Coverage (vs
|
There was a problem hiding this comment.
Code Review
This pull request refactors the TaskStore interface and its implementations (DatabaseTaskStore and InMemoryTaskStore) to enforce the use of ServerCallContext in all operations. This change ensures that the owner_resolver always has the necessary request context for determining scope boundaries, addressing a potential authorization bypass. The tests have also been updated to reflect this change.
| def test_resolve_user_default_context(): | ||
| """Test resolve_user_scope with default context.""" | ||
| assert resolve_user_scope(ServerCallContext()) == '' |
There was a problem hiding this comment.
The test test_resolve_user_default_context asserts that resolve_user_scope(ServerCallContext()) returns an empty string. This aligns with the change in resolve_user_scope where a missing user in the context results in an empty string. This test validates the behavior of the function when the context is initialized without a user.
Description
Make
ServerCallContexta mandatory parameter across allTaskStoreimplementations (TaskStoreinterface,DatabaseTaskStore, andInMemoryTaskStore) and update tests.Previously, context defaulted to None, which could allow callers to bypass authorization scoping if the context was set to None. By requiring the context, we guarantee that the
owner_resolveralways has the necessary request context to determine scope boundaries.Fixes #718 🦕