From 8d2439913cf70922c9b9bc4ff62ca7d633224b2c Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Mon, 30 Sep 2024 16:54:34 -0400 Subject: [PATCH] Remove newlines from error message Newlines can cause trouble with translations as well as presentation in the UI. This particular string doesn't actually need the newline as part of the translation string, so this commit changes it to just not have it. Alternative to ManageIQ/manageiq#23213 --- app/models/miq_provision_virt_workflow.rb | 6 +----- app/models/miq_request_workflow.rb | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/models/miq_provision_virt_workflow.rb b/app/models/miq_provision_virt_workflow.rb index ff4cdeb8b5f..91812b1e7ca 100644 --- a/app/models/miq_provision_virt_workflow.rb +++ b/app/models/miq_provision_virt_workflow.rb @@ -772,11 +772,7 @@ def self.from_ws_ver_1_0(version, user, src_name, target_name, auto_approve, tag values[:vm_tags] = p.ws_tags(tags, :parse_ws_string_v1) values[:ws_values] = p.ws_values(additional_values, :parse_ws_string_v1) - if p.validate(values) == false - errors = [] - p.fields { |_fn, f, _dn, _d| errors << f[:error] unless f[:error].nil? } - raise _("Provision failed for the following reasons:\n%{errors}") % {:errors => errors.join("\n")} - end + p.raise_validate_errors if p.validate(values) == false p.make_request(nil, values, nil, auto_approve) end diff --git a/app/models/miq_request_workflow.rb b/app/models/miq_request_workflow.rb index db362ddd297..6d5d7bd8680 100644 --- a/app/models/miq_request_workflow.rb +++ b/app/models/miq_request_workflow.rb @@ -1507,9 +1507,9 @@ def ws_schedule_fields(values, _fields, data) def raise_validate_errors errors = [] fields { |_fn, f, _dn, _d| errors << f[:error] unless f[:error].nil? } - err_text = "Provision failed for the following reasons:\n#{errors.join("\n")}" - _log.error("<#{err_text}>") - raise _("Provision failed for the following reasons:\n%{errors}") % {:errors => errors.join("\n")} + err_text = errors.join("\n").insert(0, "\n") + _log.error("") + raise _("Provision failed for the following reasons:%{errors}") % {:errors => err_text} end private