Repository navigation
Description
🔴 Required Information
Describe the Bug:
VertexAiClient.getJsonResponse never inspects the HTTP status of the API response. Any non-empty response body is parsed and returned as a success, and an empty body returns Maybe.empty(). As a result VertexAiSessionService.getSession cannot distinguish three different outcomes:
- the session genuinely does not exist (404),
- the request failed for another reason (403 / 429 / 500 with a JSON error body),
- the request failed with an empty body.
In cases 1 and 2 it constructs a Session from whatever fields it can find in the body — requested id, empty state, and lastUpdateTime null via .orElse(null). Callers observe a plausible-looking empty session instead of a miss or an error.
This is dangerous for any get-or-create pattern. A transient 500 is indistinguishable from "session not found", so an application that auto-creates on a miss will silently create a new session mid-conversation and fork the user's history, discarding prior turns. There is no signal at the call site that anything went wrong.
Both locations on main:
core/src/main/java/com/google/adk/sessions/VertexAiClient.java#L208-L219— line 216 returnsMaybe.empty()for an empty body; line 219 parses any non-empty body regardless of status.core/src/main/java/com/google/adk/sessions/VertexAiSessionService.java#L197-L221— lines 220-221 readupdateTimevia.orElse(null), producing the null-timestamp shape.
Steps to Reproduce:
- Configure
VertexAiSessionServiceagainst a Vertex AI reasoning engine. - Call
getSession(appName, userId, sessionId, Optional.empty())for a session id that does not exist. Observe aSessionis returned rather than an emptyMaybe. - Cause the GET to fail with a non-404 status that returns a JSON error body — e.g. revoke the caller's permission on the reasoning engine (403), or exceed quota (429). Observe a
Sessionis returned again, with the same shape. - Note that steps 2 and 3 are indistinguishable from each other, and from a real session that happens to have no state.
Expected Behavior:
getSession should reflect the transport outcome:
- 404 / NOT_FOUND → empty
Maybe(a real miss) - any other non-2xx → an error signalled to the caller
- 2xx → the parsed
Session
Observed Behavior:
All three produce a Session with the requested id, empty state, and lastUpdateTime == null. No exception, no log, nothing distinguishing them.
Environment Details:
- ADK Library Version: reproduced on
1.2.0; code inspected onmainafter1.8.0and unchanged - OS: macOS and Linux
- TS Version: N/A (Java)
Model Information:
- N/A — this is in the session service transport layer, independent of model choice.
🟡 Optional Information
Regression:
No — present in 1.2.0 and still present on main today. Note getSession did gain a backend-owner check since 1.2.0 ("deny as not-found so existence is not revealed"), but the status handling was not addressed.
Additional Context:
We hit this in production. Across a month of traffic our "session not found" path never fired once, because every miss was being converted into a phantom session. Separately, a burst of VertexAiClient NPEs correlated day-for-day with a spike in requests arriving with an empty session id, as callers fell back after receiving degraded responses.
Workarounds based on the returned object's shape are not reliable, which is why we think this needs fixing in the library:
- checking for a
USER_IDentry in state fails, because legitimately state-less sessions exist (we use short-lived sessions for content moderation); - checking for a null
lastUpdateTimealone fails, because 403 / 429 / 500 produce the same shape as a 404.
We currently wrap the service with a decorator that re-probes with a status-checking client and maps NOT_FOUND to an empty Maybe, propagating every other status as an error. That works but duplicates the transport layer.
Two adjacent cases we did not attempt to work around, in case they are the same root cause: the ADK collapses event-list errors into an empty conversation history, and appendEvent failures are swallowed with a warn log.
How often has this issue occurred?:
Always (100%) — it is deterministic for any non-2xx response on the session GET path.
Activity
AnupamKumar-1 commentedon Aug 28, 2026
Hi @hemasekhar-p, I was able to reproduce this issue locally and have opened PR #1467 with a fix.
hemasekhar-p commentedon Aug 28, 2026
Hi @matchajune,thank you for reporting this issue. I am able to reproduce this behavior.
@AnupamKumar-1, Thank you for you contribution and We appreciate you taking the time to submit this PR. through local testing that your fix addresses it. Currently, the issue and the associated PR are under review by our team and we will keep you updated if any additional information is required. Thank you.