diff --git a/lib/gitlab/github_import/branch_formatter.rb b/lib/gitlab/github_import/branch_formatter.rb
index f968ec4b1022e99d51a703c87451171abf0345c2..a15fc84b4182b3f5beed5005410688f4b03704cf 100644
--- a/lib/gitlab/github_import/branch_formatter.rb
+++ b/lib/gitlab/github_import/branch_formatter.rb
@@ -15,6 +15,10 @@ module Gitlab
         repo.present?
       end
 
+      def valid?
+        repo.present?
+      end
+
       private
 
       def short_id
diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb
index 361d15d991cd6739b233ea1ca68e49ddf2d37467..574737b31c1f7ad3da8e3947b790885ca4528263 100644
--- a/lib/gitlab/github_import/pull_request_formatter.rb
+++ b/lib/gitlab/github_import/pull_request_formatter.rb
@@ -29,7 +29,7 @@ module Gitlab
       end
 
       def valid?
-        !cross_project?
+        source_branch.valid? && target_branch.valid? && !cross_project?
       end
 
       def source_branch
@@ -65,8 +65,7 @@ module Gitlab
       end
 
       def cross_project?
-        source_branch_repo.present? && target_branch_repo.present? &&
-          source_branch_repo.id != target_branch_repo.id
+        source_branch_repo.id != target_branch_repo.id
       end
 
       def description
diff --git a/spec/lib/gitlab/github_import/branch_formatter_spec.rb b/spec/lib/gitlab/github_import/branch_formatter_spec.rb
index 58bfdd6c72b6bdc1763577298c095867958e6b6b..3cb634ba010bb57d5cdedeaeab4587328c0dc638 100644
--- a/spec/lib/gitlab/github_import/branch_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/branch_formatter_spec.rb
@@ -54,4 +54,18 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do
       expect(branch.sha).to eq '2e5d3239642f9161dcbbc4b70a211a68e5e45e2b'
     end
   end
+
+  describe '#valid?' do
+    it 'returns true when repository exists' do
+      branch = described_class.new(project, double(raw))
+
+      expect(branch.valid?).to eq true
+    end
+
+    it 'returns false when repository does not exist' do
+      branch = described_class.new(project, double(raw.merge(repo: nil)))
+
+      expect(branch.valid?).to eq false
+    end
+  end
 end
diff --git a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
index 5fed98e39265de864fdce96bb7328afadb260f4e..120f59e6e71fd41a926d0dd66efaa64647d01b86 100644
--- a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
@@ -173,7 +173,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
     end
 
     context 'when source repo is a fork' do
-      let(:source_repo) { double(id: 2, fork: true) }
+      let(:source_repo) { double(id: 2) }
       let(:raw_data) { double(base_data) }
 
       it 'returns false' do
@@ -182,7 +182,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
     end
 
     context 'when target repo is a fork' do
-      let(:target_repo) { double(id: 2, fork: true) }
+      let(:target_repo) { double(id: 2) }
       let(:raw_data) { double(base_data) }
 
       it 'returns false' do