Commit 233a0404 authored by Stan Hu's avatar Stan Hu

Fix Bitbucket Server importer error handler

If the Bitbucket Server importer encountered any error during a pull
request import, an `undefined local variable or method 'backtrace'`
error would previously be thrown.

1ee162b6 dropped a variable that
was needed to log a clean backtrace. We add it back now so that
error recovery will work again.

Part of https://gitlab.com/gitlab-org/gitlab/issues/197881
parent 0ca501b8
---
title: Fix Bitbucket Server importer error handler
merge_request: 23310
author:
type: fixed
......@@ -172,6 +172,7 @@ module Gitlab
stage: 'import_pull_requests', iid: pull_request.iid, error: e.message
)
backtrace = Gitlab::BacktraceCleaner.clean_backtrace(e.backtrace)
errors << { type: :pull_request, iid: pull_request.iid, errors: e.message, backtrace: backtrace.join("\n"), raw_response: pull_request.raw }
end
end
......
......@@ -67,6 +67,7 @@ describe Gitlab::BitbucketServerImport::Importer do
author_email: project.owner.email,
created_at: Time.now,
updated_at: Time.now,
raw: {},
merged?: true)
allow(subject.client).to receive(:pull_requests).and_return([pull_request])
......@@ -239,6 +240,13 @@ describe Gitlab::BitbucketServerImport::Importer do
expect(notes.first.note).to start_with('*Comment on .gitmodules')
expect(notes.second.note).to start_with('*Comment on .gitmodules')
end
it 'reports an error if an exception is raised' do
allow(subject).to receive(:import_bitbucket_pull_request).and_raise(RuntimeError)
expect(Gitlab::ErrorTracking).to receive(:log_exception)
subject.execute
end
end
describe 'inaccessible branches' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment