Merge pull request #23379 from opf/bug/75381-jira-migrator-give-not-helpful-error-message-if-user-email-is-blank

[#75381] Jira Migrator give not helpful error message if user email is blank
This commit is contained in:
Andrej
2026-05-27 11:55:22 +02:00
committed by GitHub
2 changed files with 30 additions and 4 deletions
+6 -4
View File
@@ -95,9 +95,11 @@ module Import
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/AbcSize
def import_user(jira_user)
user_attrs = jira_user.to_op_attributes
user_attrs_without_password = user_attrs.except(:password)
call = Users::CreateService
.new(user: User.system, contract_class: EmptyContract)
.call(jira_user.to_op_attributes)
.call(user_attrs)
call.on_success do |_result|
create_reference!(
@@ -119,10 +121,10 @@ module Import
)
else
raise "Existing User is expected to be found, because there was an email " \
"or login collision. See attributes: #{jira_user.to_op_attributes}"
"or login collision. See attributes: #{user_attrs_without_password}"
end
else
raise call.message
raise "Error creating a user (#{user_attrs_without_password}): #{call.message}"
end
end
@@ -155,7 +157,7 @@ module Import
raise "Existing Group is expected to be found. Group name: #{group_name}"
end
else
raise call.message
raise "Error creating a group #{group_name}: #{call.message}"
end
end
member_id = Import::JiraOpenProjectReference.where(
+24
View File
@@ -459,5 +459,29 @@ RSpec.describe Import::JiraImport do
)
end
end
context "when importing a user without email(can happen in case of LDAP)" do
let!(:jira_user) do
create(:jira_user,
jira:,
jira_import:,
payload: jira_user_payload(
key: "JIRAUSER10109",
name: "jvd@example.com",
display_name: "Jean Van Der Berg",
email: nil,
groups: []
))
end
it "raises useful error message" do
expect do
jira_import.import_users
end.to raise_error(
'Error creating a user ({login: "jvd@example.com", firstname: "Jean Van Der", lastname: "Berg", ' \
"mail: nil, status: :locked}): Email can't be blank."
)
end
end
end
end