Skip to content

fix(storage): validate blob names in Blob initialization and path_helper - #19264

Open
nidhiii-27 wants to merge 1 commit into
mainfrom
fix/storage-blob-name-validation
Open

nidhiii-27 wants to merge 1 commit into
mainfrom
fix/storage-blob-name-validation

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Blob.init and Blob.path_helper now validate object names via _validate_blob_name and raise ValueError for "." and ".." (in both str and bytes forms), matching the client-side name validation pattern used by Bucket. Valid object names containing dots or slashes (such as ".hidden", "..foo", "foo.txt", "a/./b", and "a/../b") as well as empty names at construction remain unchanged. Added unit tests for Blob.init and Blob.path_helper in tests/unit/test_blob.py.

Blob.__init__ and Blob.path_helper now validate object names via _validate_blob_name and raise ValueError for "." and ".." (in both str and bytes forms), matching the client-side name validation pattern used by Bucket. Valid object names containing dots or slashes (such as ".hidden", "..foo", "foo.txt", "a/./b", and "a/../b") as well as empty names at construction remain unchanged. Added unit tests for Blob.__init__ and Blob.path_helper in tests/unit/test_blob.py.

[Generated-by: AI]
@nidhiii-27

Copy link
Copy Markdown
Contributor Author

/gcbrun

@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 validation for blob names in the Google Cloud Storage Python client, preventing the use of "." or ".." (and their bytes equivalents) as blob names. It updates the Blob constructor and path_helper method to raise a ValueError when these invalid names are provided, and updates the corresponding docstrings. Additionally, unit tests have been added to verify that invalid names are correctly rejected while valid names containing dots are still accepted. I have no feedback to provide as the implementation is clean and well-tested.

@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 29, 2026 16:56
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 29, 2026 16:56
@nidhiii-27
nidhiii-27 removed the request for review from a team November 29, 2026 16:56
@nidhiii-27
nidhiii-27 requested review from chandra-siri and removed request for a team November 29, 2026 16:56

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants