Skip to content

fix(sessions): accept a full session resource name again on v1 - #6888

Merged
GWeale merged 2 commits into
v1from
fix-v1-session-resource-name
Aug 24, 2026
Merged

fix(sessions): accept a full session resource name again on v1#6888
GWeale merged 2 commits into
v1from
fix-v1-session-resource-name

Conversation

@GWeale

@GWeale GWeale commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Ports 60c55ad74 ("fix vertex_ai_session_service crashing when Agent Engine passes full resource names instead of short session IDs") to v1, with its regression tests.

#6809 brought _validate_session_id across, which requires a session id to match ^[A-Za-z0-9_-]+$ under fullmatch. Upstream added that check in b2916c71 and then, 13 days later, had to add _extract_short_session_id in 60c55ad74 because Agent Engine passes the full resource name rather than the short id. v1 took the check and not the follow-up, so get_session, delete_session and create_session now reject a name of the form projects/{p}/locations/{l}/reasoningEngines/{e}/sessions/{s} outright. main has accepted it since June.

  • _extract_short_session_id is ported verbatim from upstream. It returns the last path segment when the id looks like a session resource name, and raises when the embedded reasoningEngines/{id} does not match the engine the service is configured for.
  • The three call sites now resolve reasoning_engine_id first, normalize, then validate, matching upstream's ordering.
  • append_event still validates session.id without normalizing, which is what main does at :396.

Behaviour for anything that is not a session resource name is unchanged: a/b, ../foo and '' are still rejected, since the normalizer only strips when the second-to-last segment is sessions.

Tests: the four unit tests from upstream, plus two end-to-end ones covering a full resource name being accepted and a resource name for a different engine being rejected. Deleting the normalizer call makes both of the latter fail while the existing path-traversal test still passes.

The session id validation ported in #6809 requires a bare id, but Agent
Engine passes the full projects/.../sessions/{id} resource name, so
get_session, delete_session and create_session now reject it. Upstream
hit the same thing and added _extract_short_session_id 13 days after the
commit that was ported; v1 took the check without the follow-up.

Ports that normalizer verbatim and calls it before validation at the
three sites upstream patched. Ids that are not session resource names
are unaffected.
Comment thread tests/unittests/sessions/test_vertex_ai_session_service.py
The resolved session id cannot tell a correctly built resource name from
one that embedded the full name and happens to end in the same segment,
because the mock resolves on the last path segment.
@GWeale
GWeale merged commit ef4f1e0 into v1 Aug 24, 2026
13 checks passed
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.

3 participants