Skip to content

Handle 401, 403 and 404 when setting up webhooks #5589

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

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions readthedocs/oauth/services/bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ def setup_webhook(self, project):
project,
)
return (True, resp)

if resp.status_code in [401, 403, 404]:
log.info(
'Bitbucket project does not exist or user does not have '
'permissions: project=%s',
project,
)
return (False, resp)

# Catch exceptions with request or deserializing JSON
except (RequestException, ValueError):
log.exception(
Expand Down
9 changes: 9 additions & 0 deletions readthedocs/oauth/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ def setup_webhook(self, project):
project,
)
return (True, resp)

if resp.status_code in [401, 403, 404]:
log.info(
'Gitlab project does not exist or user does not have '
'permissions: project=%s',
project,
)
return (False, resp)

except (RequestException, ValueError):
log.exception(
'GitLab webhook creation failed for project: %s',
Expand Down