Quote user_id literals in VertexAiSessionService list filters#5273
Open
petrmarinec wants to merge 2 commits intogoogle:mainfrom
Open
Quote user_id literals in VertexAiSessionService list filters#5273petrmarinec wants to merge 2 commits intogoogle:mainfrom
petrmarinec wants to merge 2 commits intogoogle:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
VertexAiSessionService.list_sessions()built an AIP-160 filter by interpolating rawuser_idinto a quoted string literal. Embedded quotes could break out of that literal and append additional filter syntax.Solution:
Quote the
user_idvalue before constructing the filter string so embedded quotes and backslashes stay inside the literal. Added a regression test that captures the exact filter passed to the Vertex client for a quote-containing payload.Testing Plan
Unit Tests:
Passed locally:
PYTHONPATH=src pytest tests/unittests/sessions/test_vertex_ai_session_service.py29 passedPassed in clean Linux Docker (
python:3.11-bookworm):pip install -e '.[test]'PYTHONPATH=src pytest tests/unittests/sessions170 passedManual Validation:
origin/main, a payload ofattacker" OR user_id!=""produced the filter stringuser_id="attacker" OR user_id!="".user_id="attacker\" OR user_id!=\"\"", keeping the metacharacters inside the quoted literal.Checklist
Additional context
This is a small, focused fix that keeps the current filter construction approach but ensures
user_idvalues remain data instead of altering the filter expression.