diff --git a/app/services/project_identifiers/revert_project_to_classic_service.rb b/app/services/project_identifiers/revert_project_to_classic_service.rb index 718d3321409..da3a37a89b2 100644 --- a/app/services/project_identifiers/revert_project_to_classic_service.rb +++ b/app/services/project_identifiers/revert_project_to_classic_service.rb @@ -51,12 +51,24 @@ module ProjectIdentifiers attr_reader :project def restore_classic_identifier - generator = ProjectIdentifiers::ClassicIdentifierSuggestionGenerator.new - classic = generator.restore_identifier(project) || generator.suggest_identifier(project.name) + classic_id = identifier_generator.restore_identifier(project) || + identifier_generator.suggest_identifier(project.name) # Suppress notifications: this is a background system operation, not a user edit. Journal::NotificationConfiguration.with(false) do - project.update!(identifier: classic) + project.update!(identifier: classic_id) + rescue ActiveRecord::RecordInvalid => e + handle_update_failure(classic_id, e) end end + + def handle_update_failure(classic_id, error) + Rails.logger.warn "#{self.class}: Could not set identifier '#{classic_id}' for project #{project.id}; " \ + "falling back to a randomized suffix. (#{error.message})" + project.update!(identifier: "project-#{SecureRandom.alphanumeric(5).downcase}") + end + + def identifier_generator + @identifier_generator ||= ProjectIdentifiers::ClassicIdentifierSuggestionGenerator.new + end end end diff --git a/app/views/admin/import/jira/instances/index.html.erb b/app/views/admin/import/jira/instances/index.html.erb index 64f14227d79..a9dc8c283ce 100644 --- a/app/views/admin/import/jira/instances/index.html.erb +++ b/app/views/admin/import/jira/instances/index.html.erb @@ -93,7 +93,9 @@ See COPYRIGHT and LICENSE files for more details. title: I18n.t(:"admin.jira.run.wizard.sections.import_scope.label_supported_data"), list: [ I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.projects"), + I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.project_ids"), I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.issues"), + I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.issue_ids"), I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.issue_details"), I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.custom_fields"), I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.users"), @@ -107,8 +109,6 @@ See COPYRIGHT and LICENSE files for more details. render(Admin::Import::Jira::ImportRuns::InfoListBoxComponent.new( title: I18n.t(:"admin.jira.run.wizard.sections.import_scope.label_coming_soon"), list: [ - I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.project_ids"), - I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.issue_ids"), I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.relations"), I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.sprints"), ].map { |label| { label:, checked: false } }, diff --git a/app/views/work_packages/bulk/edit.html.erb b/app/views/work_packages/bulk/edit.html.erb index eaf3f3c30bb..ec0ea3ee155 100644 --- a/app/views/work_packages/bulk/edit.html.erb +++ b/app/views/work_packages/bulk/edit.html.erb @@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details.