Commit 8e2b06d
fix: preserve empty GCS text artifacts
Merge google#5724
## Summary
- allow `GcsArtifactService` to save `Part(text="")` as a valid text artifact
- load GCS blobs via `get_blob()` so missing objects are distinct from zero-byte objects
- add regression coverage for saving and loading an empty GCS text artifact
## Context
The file artifact backend already persists empty text artifacts, but the GCS backend checked `artifact.text` by truthiness and rejected empty strings as missing payloads. It also treated `download_as_bytes() == b""` as a missing artifact, which collapses a valid zero-byte GCS object into `None`.
This keeps the existing GCS retrieval shape for text artifacts: they load as `inline_data` with `text/plain`, matching current non-empty text behavior.
## Validation
- `uv run --extra test pytest tests/unittests/artifacts/test_artifact_service.py -q` -> 60 passed
- `uv run --extra dev pyink --check src/google/adk/artifacts/gcs_artifact_service.py tests/unittests/artifacts/test_artifact_service.py` -> passed
- `uv run --extra dev isort --check-only src/google/adk/artifacts/gcs_artifact_service.py tests/unittests/artifacts/test_artifact_service.py` -> passed
- `python3 -m py_compile src/google/adk/artifacts/gcs_artifact_service.py tests/unittests/artifacts/test_artifact_service.py` -> passed
- `git diff --check` -> passed
Co-authored-by: Bo Yang <ybo@google.com>
COPYBARA_INTEGRATE_REVIEW=google#5724 from pragnyanramtha:pragnyan/gcs-empty-text-artifacts 66aba44
PiperOrigin-RevId: 9327894251 parent 7a11b50 commit 8e2b06d
2 files changed
Lines changed: 33 additions & 4 deletions
File tree
- src/google/adk/artifacts
- tests/unittests/artifacts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | | - | |
270 | | - | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
647 | 676 | | |
648 | 677 | | |
649 | 678 | | |
| |||
0 commit comments