Skip to content

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

[#47063] more specific api error for outbound requests

Eric Schubert7ae0474fc541
diff --git a/docs/api/apiv3/paths/storage_files_prepare_upload.yml b/docs/api/apiv3/paths/storage_files_prepare_upload.yml
index c551cd0370b..768ae5afdd9 100644
--- a/docs/api/apiv3/paths/storage_files_prepare_upload.yml
+++ b/docs/api/apiv3/paths/storage_files_prepare_upload.yml
@@ -64,7 +64,7 @@ post:
errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
message: The requested resource could not be found.
description: |-
- Returned the storage does not exist or the client does not have sufficient permissions to see it.
+ Returned if the storage does not exist or the client does not have sufficient permissions to see it.
**Required permission:** view file links
'500':
@@ -74,7 +74,7 @@ post:
$ref: '../components/schemas/error_response.yml'
example:
_type: Error
- errorIdentifier: urn:openproject-org:api:v3:errors:OutboundRequestFailure
- message: An outbound request to another resource has failed with status code 404.
+ errorIdentifier: urn:openproject-org:api:v3:errors:OutboundRequest:NotFound
+ message: An outbound request to another resource has failed with status code 404.
description: |-
Returned if the outbound request to the storage has failed with any reason.
diff --git a/lib/api/errors/outbound_request_failure.rb b/lib/api/errors/outbound_request_not_found.rb
similarity index 90%
rename from lib/api/errors/outbound_request_failure.rb
rename to lib/api/errors/outbound_request_not_found.rb
index 563bf9afb08..c0b8ad90393 100644
--- a/lib/api/errors/outbound_request_failure.rb
+++ b/lib/api/errors/outbound_request_not_found.rb
@@ -28,12 +28,12 @@
module API
module Errors
- class OutboundRequestFailure < ErrorBase
- identifier 'OutboundRequestFailure'.freeze
+ class OutboundRequestNotFound < ErrorBase
+ identifier 'OutboundRequest:NotFound'.freeze
code 500
- def initialize(status_code)
- super I18n.t('api_v3.errors.code_500_outbound_request_failure', status_code:)
+ def initialize
+ super I18n.t('api_v3.errors.code_500_outbound_request_failure', status_code: 404)
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_error_helper.rb b/modules/storages/app/common/storages/peripherals/storage_error_helper.rb
index 0146ff740ad..4d95ed96f96 100644
--- a/modules/storages/app/common/storages/peripherals/storage_error_helper.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_error_helper.rb
@@ -33,7 +33,7 @@ module Storages::Peripherals
case error.code
when :not_found
- raise API::Errors::OutboundRequestFailure.new(404)
+ raise API::Errors::OutboundRequestNotFound.new
when :bad_request
raise API::Errors::BadRequest.new(error.log_message)
else