fix(artifacts): Support nested API names#6051
Open
spectaclehong wants to merge 1 commit into
Open
Conversation
Artifact services can save and list logical artifact names containing path separators, but the API routes treated artifact_name as a single path segment. This made nested names unreachable through load, version, metadata, and delete endpoints. Use path-aware artifact routes after the version-specific endpoints, and allow artifact reference URIs to parse nested filenames. Fixes google#6050
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
Artifact services can save and list logical artifact names containing
/, such asreports/summary.txt. The REST API also accepts these names throughPOST /artifactsbecause the filename is provided in the request body.However, read/version/metadata/delete routes treated
artifact_nameas a single path segment. That made nested artifact names visible in the list endpoint but unreachable through the path-based endpoints.Solution:
Update artifact read/version/metadata/delete routes to use FastAPI's
{artifact_name:path}converter so nested logical artifact names can round-trip through the REST API.Because
{artifact_name:path}is catch-all, the version-specific routes are registered before the general artifact load route. No response schema changes are intended: endpoints that returnedtypes.Partstill returntypes.Part, and metadata endpoints still returnArtifactVersion/list[ArtifactVersion].Also update artifact URI parsing so artifact references can resolve nested filenames such as
folder/file.txt.Testing Plan
Unit Tests:
Targeted artifact API tests pass locally:
Result:
Artifact service and URI tests pass locally:
Result:
Python 3.10 tox unit suite passes locally:
Result:
Pre-commit hooks pass for changed files:
Manual End-to-End (E2E) Tests:
Validated a local REST API round-trip using the ADK API server route stack with
InMemoryArtifactService:reports/summary.txt0All requests returned
200.Checklist
Additional context
No dependent changes are required.