Repository navigation
fix(artifacts): keep JSON value types in GCS artifact custom_metadata - #8402
Open
sumedh-aerram wants to merge 1 commit into
Open
sumedh-aerram wants to merge 1 commit into
sumedh-aerram wants to merge 1 commit into
Conversation
Store new custom metadata in a JSON envelope and decode it in both version readers. Preserve legacy string-valued metadata without inferring its original types. Fixes google#8401
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
Fixes #8401
Problem: GcsArtifactService applies str() to custom_metadata values. Integers, booleans, lists, and nested objects therefore change type when read through either artifact-version API. False becomes a truthy string.
Solution: Store new caller metadata in an internal JSON envelope and decode it in both version readers. Blobs without the envelope keep their legacy string mapping; service bookkeeping stays separate.
Testing Plan
Unit Tests:
python -m pytest tests/unittests/artifacts -q: 2315 passed, 26 xfailed.Regression tests against upstream before the fix: 7 cases; upstream: 2 failed and 5 passed. Both failing cases use mocked GCS (session and user scopes).
In-memory, file, and mocked GCS services; session and user namespaces; integer, float, False, null, list, nested dictionary, JSON-looking strings, empty string, Unicode, empty metadata, multiple versions, both version readers, and legacy GCS string metadata. Existing bookkeeping-filtering tests remain green.
Pre-commit passed on both changed files. Mypy passed on the changed source file with no errors; tests are excluded by the repository mypy configuration.
Manual End-to-End (E2E) Tests:
Run the offline issue reproduction. Both services print the same typed dictionary and
list matches input: True. This was executed with a scripted model or mocked storage client; no live model or GCS service was called.Checklist
Additional context
This restores existing behavior without changing public signatures or schemas. There are no dependent changes. Live service E2E testing was not performed.