Skip to content

feat(storage): demonstrate deleteSourceObjects option in compose sample#16220

Open
nidhiii-27 wants to merge 3 commits into
mainfrom
feat/compose-delete-source
Open

feat(storage): demonstrate deleteSourceObjects option in compose sample#16220
nidhiii-27 wants to merge 3 commits into
mainfrom
feat/compose-delete-source

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Update C++ compose-object sample to accept and demonstrate the deleteSourceObjects option, aligning with other SDK samples.

Update C++ compose-object sample to accept and demonstrate the deleteSourceObjects option, aligning with other SDK samples.

[Generated-by: AI]
@nidhiii-27 nidhiii-27 added ai-generated storage-sample-architect Generated by storage-sample-architect skill labels Jun 30, 2026
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Jun 30, 2026

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

Copy link
Copy Markdown

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 updates the ComposeObject sample in storage_object_samples.cc to support deleting source objects by adding a new command-line argument <delete-source-objects (true/false)>. It also adds validation for this argument and includes a corresponding test case in RunAll. The review feedback points out that the thrown usage string in ComposeObject is missing the <bucket-name> parameter, which is parsed but omitted from the usage message.

Comment on lines +508 to +509
"compose-object <destination-object-name> "
"<delete-source-objects (true/false)> <object> [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 usage string thrown here is missing the <bucket-name> parameter, which is the first argument expected by the command (parsed as bucket_name = *it++). Omitting it from the usage message can mislead users who run the command with incorrect arguments and try to follow the printed usage.

Please update the usage string to include <bucket-name>.

        "compose-object <bucket-name> <destination-object-name> "
        "<delete-source-objects (true/false)> <object> [object...]"};

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

Co-authored by AI Agent

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.23%. Comparing base (f1a8e57) to head (75f35f1).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16220   +/-   ##
=======================================
  Coverage   92.23%   92.23%           
=======================================
  Files        2265     2265           
  Lines      210205   210205           
=======================================
+ Hits       193888   193892    +4     
+ Misses      16317    16313    -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Fixes the clang-format violation in the compose-object entry.

[Generated-by: AI]
@nidhiii-27 nidhiii-27 marked this pull request as ready for review July 1, 2026 08:23
@nidhiii-27 nidhiii-27 requested review from a team as code owners July 1, 2026 08:23

@kalragauri kalragauri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We also have async samples under https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/storage/examples/storage_async_samples.cc. We should update these as well but okay to do as a follow-up.

void ComposeObject(google::cloud::storage::Client client,
std::vector<std::string> const& argv) {
using ::google::cloud::storage::examples::Usage;
if (argv.size() < 4) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other samples in this file don't perform this check manually, instead relying on the CreateCommandEntry helper:

return examples::CreateCommandEntry(name, std::move(arg_names), cmd);
.

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. We also updated the async samples in storage_async_samples.cc to support the delete option and fixed their CLI argument parsing bug.

Co-authored by AI Agent

… option

- Remove redundant manual size check in ComposeObject sample to rely on CreateCommandEntry helper.
- Update ComposeObjectRequest async sample to also support deleteSourceObjects option.
- Fix CLI argument parsing bug in async compose samples.

[Generated-by: AI]
Comment on lines +1398 to +1399
InsertObject(client, {bucket_name, temp_source_1});
InsertObject(client, {bucket_name, temp_source_2});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider calling scheduled_for_delete for these objects immediately after insertion. This safeguards cleanup if the compose request fails.

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

Labels

ai-generated api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants