fix: Starred tuple unpacking everywhere in GCS artifact service #1669
+2
−2
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.
Follow up for 3b1d9a8 -- the starred unpacking was forgotten for the
list_versions
method.Issue Description
When using GCS artifact service, including a slash in a blob's name results in a crash during the
list_versions
method.The exact crash happens on line 194 of adk.artifacts.gcs_artifact_service, in the list_versions method while iterating over blobs. The exception is raised because the blob name is split by the forward slash character, and the resulting list is unpacked with the expectation that it has exactly five elements.
Because of the semantics of the path building, it is certain that the last word is the version, regardless of the words before it. Using the starred iterable unpacking in the
list_versions
method makes it consistent with the other unpacking sites and addresses the method's intent more concretely anyway.A nice side-effect is that it permits hierarchical naming 🪄
Testing Plan
I ran the test suite with pytest ./tests/unittests, the summary results are: 2639 passed, 2 failed - but the failed seem irrelevant:
They also fail on main.
Changed the filename in
list_versions
test to include slashes and the test passes.In addition, I performed manual testing by running adk web locally against a GCS artifacts service and verified that no exceptions are raised when asking the agent to create and load artifacts.
Fixes: #1314