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

[#57147] hardened helper method for network error responses

Eric Schubert8be3417473de
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
index 3eddc4db029..81958464fcf 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
@@ -104,15 +104,18 @@ module Storages
end
def error_data_from_response(caller:, response:)
- payload =
- case response.content_type.mime_type
- when "application/json"
- response.json
- when "text/xml", "application/xml"
- response.xml
- else
- response.body.to_s
- end
+ payload = if response.respond_to?(:content_type)
+ case response.content_type.mime_type
+ when "application/json"
+ response.json
+ when "text/xml", "application/xml"
+ response.xml
+ else
+ response.body.to_s
+ end
+ else
+ response.to_s
+ end
StorageErrorData.new(source: caller, payload:)
end