Commit 99ba8ce
fix(firestore): preserve update timestamps in list_sessions
Merge #5640
### Link to Issue or Description of Change
**1. Link to an existing issue (if applicable):**
Closes: #5632
### Problem
`FirestoreSessionService.list_sessions()` always sets `Session.last_update_time` to `0.0`, even when Firestore documents contain `updateTime`.
### Solution
Use the same timestamp conversion logic as `get_session()` in `list_sessions()`:
- if `updateTime` is a `datetime`, use `.timestamp()`
- otherwise, attempt `float(updateTime)`
- fallback to `0.0` when conversion fails
This keeps list responses consistent with `get_session()` and preserves accurate update timestamps.
### Testing Plan
**Unit Tests:**
- [x] I have added or updated unit tests for my change.
- [x] All unit tests pass locally.
Updated tests:
- `test_list_sessions_with_user_id`
- `test_list_sessions_without_user_id`
Local pytest summary:
- `tests/unittests/integrations/firestore/test_firestore_session_service.py`
- `17 passed`
**Manual End-to-End (E2E) Tests:**
Reproduced with a mocked Firestore client where session docs include `updateTime`; before fix `last_update_time` was `0.0`, after fix it matches the Firestore value.
### Checklist
- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules.
Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=#5640 from kkj333:fix/firestore-list-sessions-update-time-5632 9586cc6
PiperOrigin-RevId: 9413185021 parent 5735690 commit 99ba8ce
2 files changed
Lines changed: 90 additions & 14 deletions
File tree
- src/google/adk/integrations/firestore
- tests/unittests/integrations/firestore
Lines changed: 14 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
322 | 334 | | |
323 | 335 | | |
324 | 336 | | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
387 | 389 | | |
388 | 390 | | |
389 | 391 | | |
| 392 | + | |
390 | 393 | | |
391 | 394 | | |
392 | 395 | | |
| |||
442 | 445 | | |
443 | 446 | | |
444 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
445 | 519 | | |
446 | 520 | | |
447 | 521 | | |
| |||
455 | 529 | | |
456 | 530 | | |
457 | 531 | | |
| 532 | + | |
458 | 533 | | |
459 | 534 | | |
460 | 535 | | |
| |||
503 | 578 | | |
504 | 579 | | |
505 | 580 | | |
| 581 | + | |
506 | 582 | | |
507 | 583 | | |
508 | 584 | | |
| |||
0 commit comments