Skip to content

fix(artifacts): preserve inline display names#5914

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

fix(artifacts): preserve inline display names#5914
he-yufeng wants to merge 1 commit 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
@he-yufeng he-yufeng force-pushed the fix/artifact-display-name-roundtrip branch from 6af8a81 to 9992407 Compare June 6, 2026 18:44
@he-yufeng
Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main and force-pushed the cleaned head. The PR diff is still limited to the artifact display-name roundtrip change.

Validated locally:

  • 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
  • PYTHONPATH=src C:\dev\GITHUB-clean\adk-python\.venv\Scripts\python.exe -m pytest -q tests/unittests/artifacts/test_artifact_service.py -k "display_name or inline" --basetemp .tmp\pytest-5914 -p no:cacheprovider (3 passed)
  • git diff --check upstream/main..HEAD

@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 6, 2026

I have completed the analysis for PR #5914, which addresses a key bug where the original display name of binary inline artifacts was lost during save/load pathways on disk and cloud backends.

Below is a summary of the analysis. You can also view the full detailed analysis in the premium report artifact:
📖 analysis_report.md


🔍 ADK Pull Request Analysis: PR #5914

Title: fix(artifacts): preserve inline display names
Author: @he-yufeng
Status: OPEN
Impact: 94 additions, 7 deletions across 3 files

Executive Summary

  1. Core Objective: Preserves the original inline_data.display_name property of binary/blob artifacts when saved/loaded using FileArtifactService or GcsArtifactService.
  2. Justification & Value: Justified Fix. Resolves Issue #5833. Previously, this information was lost, causing downstream converters to default to a generic name like attachment.bin.
  3. Alignment with Principles: Pass with Nits. The code structure and parametric unit tests are highly robust. Only minor typing nits are present.
  4. Recommendation: Approve with Nits.

Minor Refinement Points (Typing Nits)

To match ADK's modern typing conventions, we should request that the contributor modernize newly added or updated parameter/field annotations:

  1. In file_artifact_service.py:

    • Modernize display_name: Optional[str] inside class FileArtifactVersion to str | None.
    • Modernize parameter display_name: Optional[str] in helper _write_metadata to str | None.
  2. In gcs_artifact_service.py:

    • Modernize parameter metadata: Optional[dict[str, Any]] in private helper _user_metadata (at line 44) to dict[str, Any] | None.

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