Log Bitbucket unauthorized exceptions
What does this MR do and why?
When redirecting to Bitbucket in the import controller because of an exception we're rescuing from, we should also log it.
How to set up and validate locally
Wasn't exactly sure how to reproduce an error, so hardcoded a raise like:
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb
index d32755dbd94..0f9a9649e77 100644
--- a/app/controllers/import/bitbucket_controller.rb
+++ b/app/controllers/import/bitbucket_controller.rb
@@ -109,6 +109,7 @@ def verify_bitbucket_import_enabled
end
def bitbucket_auth
+ raise Bitbucket::Error::Unauthorized.new("error")
go_to_bitbucket_for_permissions if session[:bitbucket_token].blank?
end
Then:
- Use the instructions at https://docs.gitlab.com/ee/integration/bitbucket.html to set up the Bitbucket integration
- Go to Project -> New -> Import, from Bitbucket Cloud
And notice the error in log/exceptions_json.log
:
{"severity":"ERROR","time":"2021-11-10T21:27:08.661Z","correlation_id":"01FM5VYN379FY9EPTGE96VFTCQ", "exception.class":"Bitbucket::Error::Unauthorized","exception.message":"error","exception.backtrace": ["app/controllers/import/bitbucket_controller.rb:112:in `bitbucket_auth'",...]}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.