Skip to content

fix(artifacts): preserve inline display names#5914

Open
he-yufeng wants to merge 2 commits into
google:mainfrom
he-yufeng:fix/artifact-display-name-roundtrip
Open

fix(artifacts): preserve inline display names#5914
he-yufeng wants to merge 2 commits into
google:mainfrom
he-yufeng:fix/artifact-display-name-roundtrip

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

FileArtifactService and GcsArtifactService currently preserve the bytes and MIME type of inline_data artifacts, but drop inline_data.display_name on load. That leaves downstream converters without the user-facing filename even when the caller provided one.

This stores the display name alongside the artifact payload and restores it when loading binary artifacts:

  • file-backed artifacts persist it in the per-version metadata JSON
  • GCS-backed artifacts store it in an internal blob metadata key
  • user-supplied custom_metadata remains unchanged when artifact version metadata is listed or fetched

Fixes #5833.

Tested

  • PYTHONPATH=src python -m pytest tests/unittests/artifacts/test_artifact_service.py::test_save_load_preserves_inline_data_display_name -q
  • PYTHONPATH=src python -m py_compile src/google/adk/artifacts/file_artifact_service.py src/google/adk/artifacts/gcs_artifact_service.py tests/unittests/artifacts/test_artifact_service.py
  • python -m pyink --check src/google/adk/artifacts/file_artifact_service.py src/google/adk/artifacts/gcs_artifact_service.py tests/unittests/artifacts/test_artifact_service.py
  • git diff --check

I also ran the full artifact-service test file locally with PYTHONPATH=src. It passed all GCS/in-memory/display-name cases, with two existing Windows-only failures in tests that parse file:///C:/... URIs back with Path(unquote(parsed.path)), producing /C:/...; those are unrelated to this change.

pre-commit run --files ... passed the format/import hooks, but the two repository-local bash hooks could not run on this Windows checkout because /bin/bash is unavailable.

@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label May 30, 2026
@rohityan rohityan self-assigned this Jun 5, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 5, 2026

I have analyzed Pull Request #5914, which addresses a key bug in the ADK repository where the inline_data.display_name property of binary artifacts was discarded on save/load cycles in disk and cloud storage services.

I have compiled the comprehensive analysis into a premium PR Analysis Report artifact. Please inspect the report directly here:

📖 analysis_report.md

Key Summary of the Analysis

  • Status & Target: This PR addresses Issue #5833, resolving a bug where both FileArtifactService and GcsArtifactService lost the original file display names on save/load pathways (unlike InMemoryArtifactService).
  • Compliance Gate Passed: The contributor CLA check completed successfully on GitHub (SUCCESS state in action telemetry).
  • Recommendation: Approve with Nits. The code is exceptionally clean, covers all edge cases gracefully, introduces robust unit tests, and avoids exposing framework-internal storage keys in custom_metadata structures.

Open Decision Points & Refinements (Nits)

I recommend asking the contributor to address the following minor styling nits so the codebase maintains strict style alignment:

  1. Replace deprecated type-hints: Replace Optional[X] annotations with modern Pep-604 X | None unions across the modified sections:
    • display_name: Optional[str] in the FileArtifactVersion model should be typed as str | None.
    • _write_metadata's parameter display_name: Optional[str] in file_artifact_service.py should become str | None.
    • _user_metadata's input param metadata: Optional[dict[str, Any]] in gcs_artifact_service.py should become dict[str, Any] | None.

@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Jun 5, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

rohityan commented Jun 5, 2026

Hi @he-yufeng , Thank you for your contribution! We appreciate you taking the time to submit this pull request.

@rohityan rohityan removed the request clarification [Status] The maintainer need clarification or more information from the author label Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Blob.display_name not preserved when loading binary artifacts from FileArtifactService / GcsArtifactService

3 participants