Skip to content

fix: preserve empty GCS text artifacts#5724

Closed
pragnyanramtha wants to merge 11 commits into
google:mainfrom
pragnyanramtha:pragnyan/gcs-empty-text-artifacts
Closed

fix: preserve empty GCS text artifacts#5724
pragnyanramtha wants to merge 11 commits into
google:mainfrom
pragnyanramtha:pragnyan/gcs-empty-text-artifacts

Conversation

@pragnyanramtha

Copy link
Copy Markdown
Contributor

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

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 16, 2026 21:01
@rohityan rohityan self-assigned this May 18, 2026
@rohityan rohityan added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label May 18, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @pragnyanramtha , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan rohityan added the needs review [Status] The PR/issue is awaiting review from the maintainer label May 18, 2026
@rohityan rohityan requested a review from sasha-gitg May 18, 2026 21:48
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @sasha-gitg , can you review this. LGTM.

@pragnyanramtha

Copy link
Copy Markdown
Contributor Author

Refreshed this branch with current main in f3e84392.

Validation rerun:

  • 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
  • git diff --check

@pragnyanramtha

Copy link
Copy Markdown
Contributor Author

Refreshed this branch with current main in 35d67347.

Validation rerun:

  • 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
  • uv run --extra dev isort --check-only src/google/adk/artifacts/gcs_artifact_service.py tests/unittests/artifacts/test_artifact_service.py
  • git diff --check

@boyangsvl boyangsvl assigned boyangsvl and unassigned rohityan Jun 15, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 16, 2026
Merge #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=#5724 from pragnyanramtha:pragnyan/gcs-empty-text-artifacts 66aba44
PiperOrigin-RevId: 932789425
@adk-bot

adk-bot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Thank you @pragnyanramtha for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 8e2b06d.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Jun 16, 2026
@adk-bot adk-bot closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged needs review [Status] The PR/issue is awaiting review from the maintainer services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants