Skip to content

feat(storage): add support for object context#32902

Merged
cpriti-os merged 15 commits intogoogleapis:mainfrom
shubhangi-google:set_object_context
Apr 23, 2026
Merged

feat(storage): add support for object context#32902
cpriti-os merged 15 commits intogoogleapis:mainfrom
shubhangi-google:set_object_context

Conversation

@shubhangi-google
Copy link
Copy Markdown
Contributor

@shubhangi-google shubhangi-google commented Mar 18, 2026

This pull request introduces new functionality to the Google::Cloud::Storage::File class, enabling direct manipulation of an object's context. This enhancement provides greater control over file metadata, facilitating more nuanced data management within Google Cloud Storage.

Highlights

  • Object Contexts Support: Introduced comprehensive support for Google Cloud Storage Object Contexts, allowing users to attach custom key-value pairs to objects for enhanced metadata management.
  • Listing and Filtering: Added the ability to filter object listings based on Object Contexts, supporting queries for presence, absence, existence, and non-existence of specific context keys or key-value pairs.
  • Input Validation: Implemented validation to prevent the use of forbidden characters (double quotes) in Object Context keys and values, ensuring compatibility with GCS filter string syntax.
  • System and Unit Tests: Expanded test coverage with new system and unit tests to verify the functionality of Object Contexts across various scenarios, including creation, updates, copying, combining, and filtering.

@shubhangi-google shubhangi-google marked this pull request as ready for review March 18, 2026 07:55
@shubhangi-google shubhangi-google requested review from a team and yoshi-approver as code owners March 18, 2026 07:55
@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented Mar 18, 2026

Here is the summary of changes.

You are about to add 3 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@aandreassa aandreassa added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 19, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 19, 2026
@aandreassa aandreassa added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 21, 2026
@aandreassa
Copy link
Copy Markdown
Contributor

Temporarily adding label. We can remove next week

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this failure

  2) Failure:
Files Snippets::list_object_contexts#test_0001_filters out files on the basis of custom context key [acceptance/files_test.rb:351]:
In stdout.
--- expected
+++ actual
@@ -1,2 +1 @@
-"File: path/file_name_d3ea4590367438be3cfe6f5d5991e3ea.txt has context key: my-custom-key

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# @param [Boolean] soft_deleted If true, only soft-deleted object
# versions will be listed. The default is false.
# @param [String] filter An optional string for filtering listed objects.
# Currently only supported for the contexts field.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to change in the near future? If not lets not use Currently, just say
Supported for the contexts field or Supported fields: contexts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread google-cloud-storage/samples/storage_get_object_contexts.rb Outdated
Comment thread google-cloud-storage/acceptance/storage_helper.rb Outdated
Comment thread google-cloud-storage/test/google/cloud/storage/file_test.rb Outdated
Comment thread google-cloud-storage/test/google/cloud/storage/bucket_objects_contexts_test.rb Outdated
@cpriti-os cpriti-os removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 21, 2026
@cpriti-os cpriti-os merged commit ae22466 into googleapis:main Apr 23, 2026
13 of 16 checks passed
@github-actions github-actions Bot added the release-please:force-run To run release-please label Apr 23, 2026
@release-please release-please Bot removed the release-please:force-run To run release-please label Apr 23, 2026
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.

4 participants