Skip to content

Conversation

@krishnamd-jkp
Copy link
Contributor

No description provided.

@krishnamd-jkp krishnamd-jkp requested review from a team as code owners November 20, 2025 10:12
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @krishnamd-jkp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Go Google Cloud Storage SDK by introducing support for object contexts. This new feature allows users to associate custom key-value metadata with their objects, providing a flexible way to annotate and categorize data. Furthermore, it enables powerful filtering capabilities during object listing, allowing users to retrieve objects based on the presence, absence, or specific values of these custom contexts. The changes involve new data structures, conversion logic, and integration into existing client operations like create, update, copy, compose, and list.

Highlights

  • New Object Contexts Feature: Introduced ObjectContexts and ObjectContextValue types to allow users to attach custom key-value metadata to Google Cloud Storage objects.
  • API Integration: Updated ObjectAttrsToUpdate and ObjectAttrs to include the new Contexts field, enabling context management during object creation, updates, copies, and compositions.
  • Filtering Capabilities: Added a CustomContext field to the Query struct, allowing objects to be filtered based on the presence, absence, or specific key-value pairs of their custom contexts during list operations.
  • Client Implementation: Modified both gRPC and HTTP clients (grpc_client.go, http_client.go) to support the new context functionality for listing and updating objects.
  • Comprehensive Testing: Added extensive unit and integration tests (contexts_test.go, integration_test.go) to ensure the correct behavior of object contexts across various operations, including handling Unicode characters and context deletion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@krishnamd-jkp krishnamd-jkp force-pushed the object_contexts branch 2 times, most recently from 4dd141c to 9908107 Compare November 20, 2025 10:14
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for object contexts in the Go GCS SDK, a significant feature enhancement. The changes include new types for object contexts, conversion functions for different API layers (raw/HTTP and proto/gRPC), and updates to client methods to handle these contexts. Extensive integration tests have been added to cover various scenarios like creation, patching, copying, and listing objects with contexts. The implementation is mostly solid, but I've identified a critical bug in filter string construction and an incorrect test case for object composition. I've also included several suggestions to improve code clarity and test robustness.

@krishnamd-jkp krishnamd-jkp added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
Copy link
Contributor

@cpriti-os cpriti-os left a comment

Choose a reason for hiding this comment

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

Changes requested.

@tritone tritone changed the title feat: add object contexts in Go GCS SDK feat(storage): add object contexts in Go GCS SDK Nov 24, 2025
@tritone tritone added the api: storage Issues related to the Cloud Storage API. label Nov 24, 2025
}
}

func toStringCustomContext(cc *CustomContext) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

This has a bit of a smell to me. Is it a requirement to make a CustomContext type in each language which does this sort of cleverness? Or would it be easier to just expose Filter directly as a field on Query and allow the user to construct the appropriate filter string themself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I introduced this to just make it user friendly. It wouldn't be user friendly to expect users to give the string themselves, would it? Given it has unintuitive format like providing "-" for negation, "key=value", "key:*" etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the place to introduce this kind of a structured format would generally be in the proto message definition rather than in the SDKs. Can you check how this is implemented in other languages and/or check in with the team doing the API launch to see what they think?

Copy link
Contributor

Choose a reason for hiding this comment

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

The Java API looks like it's just using filter as a text field directly so IMO it's also fine to do that in Go https://github.com/googleapis/java-storage/pull/3329/files#diff-20bcaa643fb27f1cb3b69cd788ade6590ecec05456217cc7103513ca3a89ba94

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, this should not be part of SDK and it adds unnecessary maintenance burden.

}
}

if uattrs.Contexts != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be better to use helper function here and in http_client.go to keep UpdateObject method clean and modular?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The update logic is different for gRPC and HTTP. I think it's okay as it again follows other metadata fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants