Skip to content

fix(artifacts): keep JSON value types in GCS artifact custom_metadata - #8402

Open
sumedh-aerram wants to merge 1 commit into
google:mainfrom
sumedh-aerram:fix/gcs-artifact-metadata-types
Open

sumedh-aerram wants to merge 1 commit into
google:mainfrom
sumedh-aerram:fix/gcs-artifact-metadata-types

Conversation

@sumedh-aerram

Copy link
Copy Markdown

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:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

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

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This restores existing behavior without changing public signatures or schemas. There are no dependent changes. Live service E2E testing was not performed.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GcsArtifactService converts JSON-native custom_metadata values to strings

1 participant