Skip to content

fix(storage): handle map clears without current state#13725

Open
mahitha-ada wants to merge 1 commit into
googleapis:mainfrom
mahitha-ada:fix-storage-nested-update-masks
Open

fix(storage): handle map clears without current state#13725
mahitha-ada wants to merge 1 commit into
googleapis:mainfrom
mahitha-ada:fix-storage-nested-update-masks

Conversation

@mahitha-ada

Copy link
Copy Markdown

Fixes #12632

Summary

  • Treat empty or null blob metadata, object contexts, and bucket labels on fresh builders as root-level clears.
  • Preserve fine-grained map diffs when a builder has original state or receives non-empty updates.
  • Add production integration coverage for updates built without fetching the current resource first.

Root cause

Fresh builders start with null map fields. Updating them to an empty or null value produced no nested differences, so the update mask remained empty and the client performed a read instead of clearing the remote field.

Validation

  • mvn -pl google-cloud-storage -DskipTests fmt:format (Java 21)
  • mvn -pl google-cloud-storage -am -Dtest=ITUpdateMaskTest,BlobInfoTest,BucketInfoTest -Dsurefire.failIfNoSpecifiedTests=false test (82 tests)
  • git diff --check

@mahitha-ada mahitha-ada marked this pull request as ready for review July 9, 2026 23:43
@mahitha-ada mahitha-ada requested review from a team as code owners July 9, 2026 23:43

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a hasOriginalState flag to the builders of BlobInfo and BucketInfo to track whether they were initialized with an existing instance's state. This flag helps correctly identify when fields like metadata, contexts, or labels are being cleared on a new builder, ensuring they are properly marked as modified during updates. Additionally, several integration tests have been added to verify this behavior. I have no feedback to provide as there are no review comments to evaluate.

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.

[java-storage] metadata/label diffing logic can fail to update sometimes

1 participant