Skip to content

fix(requester pays): Set context in grpc client if user project is set for ListObjects#14449

Draft
meet2mky wants to merge 1 commit intogoogleapis:mainfrom
meet2mky:main
Draft

fix(requester pays): Set context in grpc client if user project is set for ListObjects#14449
meet2mky wants to merge 1 commit intogoogleapis:mainfrom
meet2mky:main

Conversation

@meet2mky
Copy link
Copy Markdown

No description provided.

@meet2mky meet2mky requested review from a team as code owners April 17, 2026 06:42
Copy link
Copy Markdown
Contributor

@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 updates the ListObjects method in storage/grpc_client.go to ensure the iterator's context includes the userProject metadata. Feedback suggests refactoring the logic to prepare the context before the iterator is initialized, which would improve maintainability and ensure consistency with other methods in the codebase.

Comment thread storage/grpc_client.go
Comment on lines 559 to +561
if s.userProject != "" {
ctx = setUserProjectMetadata(ctx, s.userProject)
it.ctx = ctx
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.

medium

To improve maintainability and robustness, consider ensuring the context is fully prepared with all necessary metadata (such as the userProject) before the iterator is initialized. This avoids the need for manual field updates and reduces the risk of the iterator's internal state becoming out of sync with the local context variable. Moving this logic before the initialization of it would also align with the pattern used in other methods like ListBuckets.

@meet2mky meet2mky marked this pull request as draft April 17, 2026 06:48
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