Skip to content

fix(firestore): populate last_update_time in list_sessions from Firestore updateTime#5642

Closed
nileshpatil6 wants to merge 1 commit intogoogle:mainfrom
nileshpatil6:fix/firestore-list-sessions-timestamp
Closed

fix(firestore): populate last_update_time in list_sessions from Firestore updateTime#5642
nileshpatil6 wants to merge 1 commit intogoogle:mainfrom
nileshpatil6:fix/firestore-list-sessions-timestamp

Conversation

@nileshpatil6
Copy link
Copy Markdown

Fixes #5632

Problem

list_sessions() hardcodes last_update_time=0.0 in every returned Session, silently ignoring the updateTime field stored in the Firestore document. This means callers can never sort or filter sessions by last-update time when using FirestoreSessionService.

get_session() already handles this correctly:

# Convert timestamp
update_time = data.get("updateTime")
last_update_time = 0.0
if update_time:
    if isinstance(update_time, datetime):
        last_update_time = update_time.timestamp()
    else:
        try:
            last_update_time = float(update_time)
        except (ValueError, TypeError):
            pass

list_sessions() was missing this block entirely.

Fix

Apply the same timestamp conversion in the list_sessions() loop, immediately before constructing each Session. The datetime import is already present at the top of the file.

Behavior

  • Before: session.last_update_time is always 0.0 for every session returned by list_sessions()
  • After: session.last_update_time reflects the actual Firestore updateTime (a POSIX timestamp float)

No other behavior changes -- the fix is additive and cannot break existing callers since 0.0 was always wrong.

…tore updateTime

list_sessions() was hardcoding last_update_time=0.0 in every returned
Session, ignoring the updateTime field stored in the Firestore document.
get_session() already handles this correctly with an isinstance(datetime)
check and a float() fallback. This commit applies the same conversion block
to list_sessions().

Fixes google#5632
@kkj333
Copy link
Copy Markdown

kkj333 commented May 8, 2026

Thanks for working on this! This seems to overlap with #5640 (opened earlier),
which includes the same fix and unit tests.
Could we consolidate into one PR to avoid duplication?

@nileshpatil6
Copy link
Copy Markdown
Author

Thanks for the pointer @kkj333 — closing this in favour of #5640 which was opened first and already includes unit tests. Good to see this getting fixed!

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.

Firestore Session Service does not handle timestamp correctly

2 participants