summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/blame_controller.rb3
-rw-r--r--changelogs/unreleased/fix-blame-500.yml4
-rw-r--r--spec/controllers/projects/blame_controller_spec.rb5
3 files changed, 12 insertions, 0 deletions
diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb
index f576d0be1fc..863a766a255 100644
--- a/app/controllers/projects/blame_controller.rb
+++ b/app/controllers/projects/blame_controller.rb
@@ -8,6 +8,9 @@ class Projects::BlameController < Projects::ApplicationController
def show
@blob = @repository.blob_at(@commit.id, @path)
+
+ return render_404 unless @blob
+
@blame_groups = Gitlab::Blame.new(@blob, @commit).groups
end
end
diff --git a/changelogs/unreleased/fix-blame-500.yml b/changelogs/unreleased/fix-blame-500.yml
new file mode 100644
index 00000000000..379d81aaa44
--- /dev/null
+++ b/changelogs/unreleased/fix-blame-500.yml
@@ -0,0 +1,4 @@
+---
+title: Fix blame 500 error on invalid path.
+merge_request: 25761
+author: Jeff Stubler
diff --git a/spec/controllers/projects/blame_controller_spec.rb b/spec/controllers/projects/blame_controller_spec.rb
index 25f06299a29..4402ca43c65 100644
--- a/spec/controllers/projects/blame_controller_spec.rb
+++ b/spec/controllers/projects/blame_controller_spec.rb
@@ -25,5 +25,10 @@ describe Projects::BlameController do
let(:id) { 'master/files/ruby/popen.rb' }
it { is_expected.to respond_with(:success) }
end
+
+ context "invalid file" do
+ let(:id) { 'master/files/ruby/missing_file.rb'}
+ it { expect(response).to have_http_status(404) }
+ end
end
end