OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
return proper JSON errors on 404
ulferts0669bd92d15b
diff --git a/lib/api/v3/root.rb b/lib/api/v3/root.rbindex 1d2e22b576c..8deeb4b61d6 100644--- a/lib/api/v3/root.rb+++ b/lib/api/v3/root.rb@@ -101,6 +101,12 @@ module APIAPI::OpenAPI.spec.to_yamlend++ # Catch all unknown routes (therefore have it at the end of the file)+ # and return a properly formatted 404 error.+ route :any, "*path" do+ raise API::Errors::NotFound+ endendendenddiff --git a/modules/budgets/spec/requests/api/v3/budgets/budget_resource_spec.rb b/modules/budgets/spec/requests/api/v3/budgets/budget_resource_spec.rbindex 84c1815c169..9e769c15723 100644--- a/modules/budgets/spec/requests/api/v3/budgets/budget_resource_spec.rb+++ b/modules/budgets/spec/requests/api/v3/budgets/budget_resource_spec.rb@@ -61,9 +61,7 @@ RSpec.describe "API v3 Budget resource" docontext "invalid id" dolet(:get_path) { api_v3_paths.budget "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- end+ it_behaves_like "not found"endenddiff --git a/modules/costs/spec/requests/api/cost_entries/cost_entry_resource_spec.rb b/modules/costs/spec/requests/api/cost_entries/cost_entry_resource_spec.rbindex 5d7c8175551..094ffd7e747 100644--- a/modules/costs/spec/requests/api/cost_entries/cost_entry_resource_spec.rb+++ b/modules/costs/spec/requests/api/cost_entries/cost_entry_resource_spec.rb@@ -62,9 +62,7 @@ RSpec.describe "API v3 Cost Entry resource" docontext "invalid id" dolet(:get_path) { api_v3_paths.cost_type "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- end+ it_behaves_like "not found"endenddiff --git a/modules/costs/spec/requests/api/cost_types/cost_type_resource_spec.rb b/modules/costs/spec/requests/api/cost_types/cost_type_resource_spec.rbindex 763b914271e..f66ce9964af 100644--- a/modules/costs/spec/requests/api/cost_types/cost_type_resource_spec.rb+++ b/modules/costs/spec/requests/api/cost_types/cost_type_resource_spec.rb@@ -67,9 +67,7 @@ RSpec.describe "API v3 Cost Type resource" docontext "invalid id" dolet(:get_path) { api_v3_paths.cost_type "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- end+ it_behaves_like "not found"endenddiff --git a/modules/meeting/spec/requests/api/v3/meetings/meetings_resource_spec.rb b/modules/meeting/spec/requests/api/v3/meetings/meetings_resource_spec.rbindex 5d95cc0309f..094095c8939 100644--- a/modules/meeting/spec/requests/api/v3/meetings/meetings_resource_spec.rb+++ b/modules/meeting/spec/requests/api/v3/meetings/meetings_resource_spec.rb@@ -69,9 +69,7 @@ RSpec.describe "API v3 Meeting resource" docontext "when invalid id" dolet(:get_path) { api_v3_paths.budget "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- end+ it_behaves_like "not found"endenddiff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rbindex 6364eed3f47..3375e552ec3 100644--- a/spec/features/work_packages/navigation_spec.rb+++ b/spec/features/work_packages/navigation_spec.rb@@ -259,7 +259,7 @@ RSpec.describe "Work package navigation", :js, :selenium dovisit "/projects/#{project.identifier}/work_packages?#{url_query}"wp_table.expect_toast message: "Your view is erroneous and could not be processed.", type: :error- expect(page).to have_css "li", text: "Bad request: id is invalid"+ expect(page).to have_css "li", text: "The requested resource could not be found"endendenddiff --git a/spec/requests/api/v3/category_resource_spec.rb b/spec/requests/api/v3/category_resource_spec.rbindex b4ad3aaea0e..b994ec4ce77 100644--- a/spec/requests/api/v3/category_resource_spec.rb+++ b/spec/requests/api/v3/category_resource_spec.rb@@ -100,10 +100,7 @@ RSpec.describe "API v3 Category resource" docontext "invalid priority id" dolet(:get_path) { api_v3_paths.category "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- let(:type) { "Category" }- end+ it_behaves_like "not found"endend@@ -116,10 +113,7 @@ RSpec.describe "API v3 Category resource" doget get_pathend- it_behaves_like "param validation error" do- let(:id) { "bogus" }- let(:type) { "Category" }- end+ it_behaves_like "not found"endendenddiff --git a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rbindex 5a56e499fd9..cccdb84c983 100644--- a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb+++ b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb@@ -92,10 +92,7 @@ RSpec.describe "API v3 Help texts resource" docontext "invalid type id" dolet(:get_path) { api_v3_paths.type "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- let(:type) { "HelpText" }- end+ it_behaves_like "not found"endcontext "invisible type id" dodiff --git a/spec/requests/api/v3/priority_resource_spec.rb b/spec/requests/api/v3/priority_resource_spec.rbindex 38547bf77dc..b7f93bdb39b 100644--- a/spec/requests/api/v3/priority_resource_spec.rb+++ b/spec/requests/api/v3/priority_resource_spec.rb@@ -86,10 +86,7 @@ RSpec.describe "API v3 Priority resource" docontext "invalid priority id" dolet(:get_path) { api_v3_paths.priority "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- let(:type) { "IssuePriority" }- end+ it_behaves_like "not found"endenddiff --git a/spec/requests/api/v3/status_resource_spec.rb b/spec/requests/api/v3/status_resource_spec.rbindex 58bbd0bb25f..f9c83ad1941 100644--- a/spec/requests/api/v3/status_resource_spec.rb+++ b/spec/requests/api/v3/status_resource_spec.rb@@ -88,10 +88,7 @@ RSpec.describe "API v3 Status resource" docontext "invalid status id" dolet(:get_path) { api_v3_paths.status "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- let(:type) { "Status" }- end+ it_behaves_like "not found"endenddiff --git a/spec/requests/api/v3/types/type_resource_spec.rb b/spec/requests/api/v3/types/type_resource_spec.rbindex dd21d89a94e..2b6934a37eb 100644--- a/spec/requests/api/v3/types/type_resource_spec.rb+++ b/spec/requests/api/v3/types/type_resource_spec.rb@@ -88,10 +88,7 @@ RSpec.describe "API v3 Type resource" docontext "invalid type id" dolet(:get_path) { api_v3_paths.type "bogus" }- it_behaves_like "param validation error" do- let(:id) { "bogus" }- let(:type) { "Type" }- end+ it_behaves_like "not found"endend