-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch forbidden errors as notfound #33148
Conversation
R: @shunping |
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
@@ -172,7 +173,7 @@ def get_bucket(self, bucket_name, **kwargs): | |||
try: | |||
return self.client.lookup_bucket( | |||
bucket_name, retry=self._storage_client_retry, **kwargs) | |||
except NotFound: | |||
except (Forbidden, NotFound): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method that is failing exists() [1], which calls _gcs_object().
The Forbidden error mentions it can be a permission issue or the bucket does not exist. So we might swallow actual permission issues too.
I think we can list the buckets with a prefix to check for existence explicitly.
client.list_buckets(prefix=bucket_name)
[1]
beam/sdks/python/apache_beam/io/gcp/gcsio.py
Line 404 in 8da9bbe
def exists(self, path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right about it being exists, I added it there as well.
The Forbidden error mentions it can be a permission issue or the bucket does not exist. So we might swallow actual permission issues too.
I think this is going to be true even if we do what you're suggesting. If there are permissions issues, the bucket won't show up in our list call either
Closing in favor of #33151 |
When getting a bucket, if the bucket does not exist it can manifest as forbidden as well (basically, the error is "I don't know if this bucket exists or not"). In those cases, we should probably treat the bucket as not found. This is currently causing some precommit failures, for example https://github.com/apache/beam/actions/runs/11888837746/job/33124186007
Fixes #31285
Fixes #30813
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.