Skip to content

feat(storage): add Object Contexts samples and system tests#1

Open
salilg-eng wants to merge 5 commits intomainfrom
feat/sample-object-contexts
Open

feat(storage): add Object Contexts samples and system tests#1
salilg-eng wants to merge 5 commits intomainfrom
feat/sample-object-contexts

Conversation

@salilg-eng
Copy link
Copy Markdown
Owner

Add set_object_contexts.php to demonstrate upload contexts.
Add get_object_contexts.php to show retrieval of structured metadata.
Add list_object_contexts.js to demonstrate server-side filtering.
Implement comprehensive system tests in storageTest.php covering presence, absence (-), and existence (:) filter operators.
Ensure samples use the correct 'contexts' field with 'custom' map structure.

@salilg-eng
Copy link
Copy Markdown
Owner Author

/Gemini review

Copy link
Copy Markdown

@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 new PHP code samples for managing Google Cloud Storage object contexts, including scripts to set, retrieve, and list objects based on custom context metadata. It also adds a comprehensive test case in storageTest.php. The review feedback identifies several inaccuracies in the docstrings and output messages for the retrieval and listing functions, which currently incorrectly describe their purpose as attaching or modifying contexts.

Comment thread storage/src/get_object_contexts.php Outdated
use Google\Cloud\Storage\StorageClient;

/**
* Attach or modify contexts to an existing object.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The docstring for this function is incorrect. It describes attaching or modifying contexts, but this function is intended to retrieve them.

 * Retrieve contexts for an existing object.

Comment thread storage/src/get_object_contexts.php Outdated

$info = $object->info();
if (isset($info['contexts']['custom'])) {
printf('Contexts for object %s were updated:' . PHP_EOL, $objectName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The output message "were updated" is misleading for a retrieval sample. It should reflect that the contexts are being displayed or retrieved.

        printf('Contexts for object %s:' . PHP_EOL, $objectName);

Comment thread storage/src/list_object_contexts.php Outdated
use Google\Cloud\Storage\StorageClient;

/**
* Attach or modify contexts to an existing object.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The docstring for this function is incorrect. It describes attaching or modifying contexts, but this function is intended to list objects using a filter.

 * List objects with a filter based on contexts.

Copy link
Copy Markdown

@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 new sample scripts for managing Google Cloud Storage object contexts, including functionality for setting, retrieving, and listing objects using context filters. It also includes a new test case to verify these operations. The review feedback identifies several documentation errors where docstrings were likely copied from other functions and a misleading output message in the retrieval script that incorrectly implies an update operation.

Comment thread storage/src/get_object_contexts.php Outdated
use Google\Cloud\Storage\StorageClient;

/**
* Attach or modify contexts to an existing object.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The docstring for this function is incorrect. It appears to be a copy-paste from the set_object_contexts function. It should describe the retrieval of contexts.

 * Retrieve contexts of an existing object.

Comment thread storage/src/get_object_contexts.php Outdated

$info = $object->info();
if (isset($info['contexts']['custom'])) {
printf('Contexts for object %s were updated:' . PHP_EOL, $objectName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The output message says 'were updated', which is misleading for a retrieval (GET) operation. It should simply state that these are the contexts for the object.

        printf('Contexts for object %s:' . PHP_EOL, $objectName);

Comment thread storage/src/list_object_contexts.php Outdated
use Google\Cloud\Storage\StorageClient;

/**
* Attach or modify contexts to an existing object.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The docstring for this function is incorrect. It should describe listing objects using a context filter rather than attaching or modifying them.

 * List objects with a specific context filter.

@salilg-eng salilg-eng self-assigned this Apr 17, 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.

1 participant