feat(storage): implement Object Contexts with advanced filtering and validation#9122
feat(storage): implement Object Contexts with advanced filtering and validation#9122salilg-eng wants to merge 75 commits intogoogleapis:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
| "value": { | ||
| "type": "string", | ||
| "description": "The value of the object contexts.", | ||
| "required": true |
There was a problem hiding this comment.
The value field is marked as required here, but in the official discovery doc, this field is not marked as required
There was a problem hiding this comment.
Removed required
| if (!is_array($options['contexts'])) { | ||
| throw new \InvalidArgumentException('Object contexts must be an array.'); | ||
| } | ||
| $this->validateContexts($options['contexts']); |
There was a problem hiding this comment.
This manual regex validation is not needed at the client level. The SDKs rely on the GCS server-side API to validate context keys and values. Hardcoding these rules on the client side is redundant and could lead to issues if the GCS service updates its naming requirements. We should only verify that the input is an array and let the API handle the validation, consistent with how we handle other custom metadata.
There was a problem hiding this comment.
Removed ValidateContext. Thanks for your clarity.
| * Each object context is a key-payload pair, where the key provides the | ||
| * identification and the payload holds the associated value and additional metadata. | ||
| * @type array $contexts.custom Custom user-defined contexts. Keys must start | ||
| * with an alphanumeric character and cannot contain double quotes (`"`). |
There was a problem hiding this comment.
Need not mention these specific details here, you can add the link to the API docs - https://docs.cloud.google.com/storage/docs/use-object-contexts
There was a problem hiding this comment.
Removed and added link as per given by you.
| * @type array $contexts.custom Custom user-defined contexts. Keys must start | ||
| * with an alphanumeric character and cannot contain double quotes (`"`). | ||
| * @type string $contexts.custom.{key}.value The value associated with the context. | ||
| * If not empty, must start with an alphanumeric character and cannot contain double quotes (`"`) |
| * Each object context is a key-payload pair, where the key provides the | ||
| * identification and the payload holds the associated value and additional metadata. | ||
| * @type array $contexts.custom Custom user-defined contexts. Keys must start | ||
| * with an alphanumeric character and cannot contain double quotes (`"`). |
There was a problem hiding this comment.
Update the comments here as well. We don't need to add specific restrictions here.
There was a problem hiding this comment.
changed as per above feedback.
|
"Hello, thank you for the feedback. The CLA is now approved, and I have addressed all your comments and resolved the issues." |
Co-authored-by: Nidhi <nidhiii@google.com>
…google-cloud-php into feat/object-contexts
|
@salilg-eng Can you please look into the failing tests? |
| { | ||
| const DATA = 'data'; | ||
|
|
||
There was a problem hiding this comment.
Are these white spaces? If so, let's remove them :)
There was a problem hiding this comment.
Removed the extra whitespace. I’ve double-checked the rest of the code, and no other instances remain.
storage-v1.jsonto include thecontextsobject definition, enabling the library to recognize context metadata in requests and responses.Rest.phpto includecontextsin the request body during object creation. This ensures that context properties are correctly serialized as part of the object resource.validate contextstructures early in the execution lifecycle, preventing unnecessary API calls for malformed metadata.operations, and complex filtering scenarios.