Skip to content

Test Cases 500 instead of 404ing when record not found

Summary

Test Cases should 404 when they 500 instead.

This fails because the record is not found but instead raising an exception, the @test_case ivar is assigned nil and the first method called on it fails. This happens to be ee/app/views/projects/quality/test_cases/show.html.haml:3 and undefined method 'to_reference' for nil:NilClass.

Steps to reproduce

  1. Go to any test case URL with an iid that doesn't exist, see example project.

Example Project

https://gitlab.com/gitlab-org/plan/-/quality/test_cases/3773333

What is the current bug behavior?

A 500 error is shown.

What is the expected correct behavior?

A 404 is shown.

Possible fixes

Raise a RecordNotFound exception and let Rails handle the 404 instead of assigning nil to @test_case.

Edited by John Hope