Salt state import fails on 3.10 @ EL9 due to salt-state names being considered invalid for ActiveRecord

Problem:
Importing salt states with substates (aka. state.somesubstate.sls or some.state.with._nesting.sls) fails due to ActiveRecord validation. This was not the case in Foreman 3.9 on EL8.

Expected outcome:
States are imported successfully.

Foreman and Proxy versions:
Foreman version: 3.10.0

Foreman and Proxy plugin versions:
Foreman version: 3.10.0
Plugins:

  • foreman-tasks 9.1.1
  • foreman_default_hostgroup 7.0.0
  • foreman_remote_execution 12.0.5
  • foreman_salt 16.0.0
  • foreman_templates 9.4.0
  • katello 4.12.0

Distribution and version:
AlmaLinux 9.3

Other relevant data:

Foreman version: 3.10.0
Plugins:
 - foreman-tasks 9.1.1
 - foreman_default_hostgroup 7.0.0
 - foreman_remote_execution 12.0.5
 - foreman_salt 16.0.0
 - foreman_templates 9.4.0
 - katello 4.12.0

2024-04-08T09:57:58 [I|app|94b17b40] Started POST "/salt/salt_modules/apply_changes" for <Redacted IP w.x.y.z> at 2024-04-08 09:57:58 +0200
2024-04-08T09:57:58 [I|app|94b17b40] Processing by ForemanSalt::SaltModulesController#apply_changes as HTML
2024-04-08T09:57:58 [I|app|94b17b40]   Parameters: {"authenticity_token"=>"**redacted***", "changed"=>{"***redacted-saltenv***"=>{"add"=>"[\"backup\",\"check_apt_update\",\"cpufrequtils\",\"crontab\",\"curl\",\"da_acl\",\"da_acl.install\",\"da_acl.remove-acl-permissions\",\"da_acl.remove-dependencies\",\"da_acl.set-acl-permissions\",\"da_acl.uninstall\",\"da_adopt_openjdk\",\"da_adopt_openjdk.install\",\"da_apt\",\"da_apt.install\",\"da_auditd.config\",\"da_auditd\",\"da_auditd.install\",\"da_auditd.service\",\"da_backup.inhouse\",\"da_backup\",\"da_backup.remote\",\"da_build_utils\",\"da_common_packages\",\"da_crond.config\",\"da_crond\",\"da_docker\",\"da_docker.install\",\"da_elk.backup\",\"da_elk.config\",\"da_elk\",\"da_elk.install\",\"da_elk.service\",\"da_java\",\"da_java.install\",\"da_jenkins.agent.config\",\"da_jenkins.agent\",\"da_jenkins.agent.ssh\",\"da_jenkins.agent.uninstall\",\"da_jenkins\",\"da_jenkins.server.config\",\"da_jenkins.server\",\"da_jenkins.server.install\",\"da_jenkins.server.service\",\"da_jenkins.server.ssh\",\"da_jenkins.user\",\"da_jenkins.user_delete\",\"da_known_hosts.config\",\"da_known_hosts\",\"da_kvm.guest_backup\",\"da_kvm.guest_install\",\"da_kvm.guest_uninstall\",\"da_kvm.host_install\",\"da_kvm.host_uninstall\",\"da_kvm\",\"da_locales.config\",\"da_locales\",\"da_locales.install\",\"da_logrotate.config\",\"da_logrotate\",\"da_logrotate.install\",\"da_mdadm\",\"da_mount_smb.config\",\"da_mount_smb\",\"da_mount_smb.install\",\"da_nfs_client.client_config\",\"da_nfs_client.client_install\",\"da_nfs_client\",\"da_nfs_client.rpc_disable\",\"da_nfs_server\",\"da_nfs_server.server_install\",\"da_ntp\",\"da_ntp.install\",\"da_ntp.service\",\"da_php.config-81\",\"da_php\",\"da_php.install-81\",\"da_php.php81\",\"da_php.service-81\",\"da_postgresql.databases\",\"da_postgresql\",\"da_postgresql.install\",\"da_postgresql.users\",\"da_proxysql.config\",\"da_proxysql\",\"da_proxysql.install\",\"da_proxysql.service\",\"da_python3\",\"da_python3.install\",\"da_redis.cluster_init\",\"da_redis.config\",\"da_redis\",\"da_redis.install\",\"da_redis.service\",\"da_rsyslog.config\",\"da_rsyslog\",\"da_rsyslog.install\",\"da_rsyslog.service\",\"da_service_systemd.config\",\"da_service_systemd\",\"da_service_systemd.service\",\"da_smartctl\",\"da_smartctl.install\",\"da_smartctl.service\",\"da_sonarscanner\",\"da_sonarscanner.install\",\"da_ssh.config\",\"da_ssh\",\"da_ssh.install\",\"da_ssl.config\",\"da_ssl\",\"da_teststate\",\"da_tools\",\"da_tools.install\",\"environment\",\"grub\",\"hostname\",\"hosts\",\"lldpd\",\"lvm2\",\"mail\",\"mc\",\"memcached\",\"nano\",\"network\",\"nginx\",\"pcregrep\",\"pdns\",\"resolv\",\"salt_config\",\"salt_config.install_master\",\"salt_config.install_minion\",\"snmpd\",\"stunnel\",\"sysctl._mapdata\",\"sysctl\",\"sysctl.package\",\"sysctl.param\",\"sysstat\",\"tzdata\",\"ulimit\",\"users._mapdata\",\"users.bashrc\",\"users.googleauth\",\"users\",\"users.polkit\",\"users.profile\",\"users.sudo\",\"users.user_files\",\"users.vimrc\",\"vim._mapdata\",\"vim.absent\",\"vim.editor\",\"vim\",\"vim.nerdtree\",\"vim.pyflakes\",\"vim.salt\"]"}}, "commit"=>"Update"}
2024-04-08T09:57:58 [W|app|94b17b40] Validation failed: Name is alphanumeric and cannot contain spaces
2024-04-08T09:57:58 [I|app|94b17b40] Backtrace for 'Validation failed: Name is alphanumeric and cannot contain spaces' error (ActiveRecord::RecordInvalid): Validation failed: Name is alphanumeric and cannot contain spaces
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/validations.rb:80:in `raise_validation_error'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/validations.rb:53:in `save!'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/transactions.rb:302:in `block in save!'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/transactions.rb:302:in `save!'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/suppressor.rb:48:in `save!'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:371:in `insert_record'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/has_many_association.rb:58:in `insert_record'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/has_many_through_association.rb:28:in `insert_record'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:437:in `block (2 levels) in concat_records'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:462:in `replace_on_target'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:283:in `add_to_target'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:435:in `block in concat_records'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:433:in `each'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:433:in `concat_records'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/has_many_association.rb:130:in `concat_records'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/has_many_through_association.rb:40:in `concat_records'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:121:in `block in concat'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:136:in `block in transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/transactions.rb:209:in `transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:135:in `transaction'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_association.rb:121:in `concat'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/has_many_through_association.rb:21:in `concat'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/associations/collection_proxy.rb:1027:in `<<'
 94b17b40 | /usr/share/gems/gems/foreman_salt-16.0.0/app/controllers/foreman_salt/state_importer.rb:52:in `block in add_to_environment'
 94b17b40 | /usr/share/gems/gems/foreman_salt-16.0.0/app/controllers/foreman_salt/state_importer.rb:50:in `each'
 94b17b40 | /usr/share/gems/gems/foreman_salt-16.0.0/app/controllers/foreman_salt/state_importer.rb:50:in `add_to_environment'
 94b17b40 | /usr/share/gems/gems/foreman_salt-16.0.0/app/controllers/foreman_salt/salt_modules_controller.rb:77:in `block in apply_changes'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/strong_parameters.rb:389:in `block in each_pair'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/strong_parameters.rb:388:in `each_pair'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/strong_parameters.rb:388:in `each_pair'
 94b17b40 | /usr/share/gems/gems/foreman_salt-16.0.0/app/controllers/foreman_salt/salt_modules_controller.rb:74:in `apply_changes'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/base.rb:228:in `process_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 94b17b40 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 94b17b40 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 94b17b40 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 94b17b40 | /usr/share/gems/gems/audited-5.4.3/lib/audited/sweeper.rb:16:in `around'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 94b17b40 | /usr/share/gems/gems/audited-5.4.3/lib/audited/sweeper.rb:16:in `around'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:137:in `run_callbacks'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/callbacks.rb:41:in `process_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/rescue.rb:22:in `process_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `block in instrument'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:203:in `instrument'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 94b17b40 | /usr/share/gems/gems/activerecord-6.1.7.7/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/abstract_controller/base.rb:165:in `process'
 94b17b40 | /usr/share/gems/gems/actionview-6.1.7.7/lib/action_view/rendering.rb:39:in `process'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal.rb:190:in `dispatch'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_controller/metal.rb:254:in `dispatch'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/journey/router.rb:32:in `each'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/journey/router.rb:32:in `serve'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/routing/route_set.rb:842:in `call'
 94b17b40 | /usr/share/gems/gems/katello-4.12.0/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 94b17b40 | /usr/share/gems/gems/katello-4.12.0/lib/katello/middleware/event_daemon.rb:10:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/apipie-dsl-2.6.2/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 94b17b40 | /usr/share/gems/gems/apipie-rails-1.3.0/lib/apipie/static_dispatcher.rb:74:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/static.rb:24:in `call'
 94b17b40 | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 94b17b40 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 94b17b40 | /usr/share/gems/gems/apipie-rails-1.3.0/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb:15:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/etag.rb:27:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/conditional_get.rb:40:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 94b17b40 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:266:in `context'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:260:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/cookies.rb:697:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:98:in `run_callbacks'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 94b17b40 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/rack/logger.rb:37:in `call_app'
 94b17b40 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/rack/logger.rb:28:in `call'
 94b17b40 | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 94b17b40 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 94b17b40 | /usr/share/gems/gems/request_store-1.6.0/lib/request_store/middleware.rb:19:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 94b17b40 | /usr/share/gems/gems/katello-4.12.0/lib/katello/prevent_json_parsing.rb:12:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/runtime.rb:22:in `call'
 94b17b40 | /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/executor.rb:14:in `call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/sendfile.rb:110:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 94b17b40 | /usr/share/gems/gems/actionpack-6.1.7.7/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 94b17b40 | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in `call'
 94b17b40 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/engine.rb:539:in `call'
 94b17b40 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `public_send'
 94b17b40 | /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `method_missing'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
 94b17b40 | /usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
 94b17b40 | /usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'
 94b17b40 | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2024-04-08T09:57:58 [I|app|94b17b40]   Rendered common/500.html.erb within layouts/application (Duration: 0.7ms | Allocations: 679)
2024-04-08T09:57:58 [I|app|94b17b40]   Rendered layouts/base.html.erb (Duration: 2.1ms | Allocations: 1830)
2024-04-08T09:57:58 [I|app|94b17b40]   Rendered layout layouts/application.html.erb (Duration: 3.1ms | Allocations: 2782)
2024-04-08T09:57:58 [I|app|94b17b40] Completed 500 Internal Server Error in 15ms (Views: 3.4ms | ActiveRecord: 2.4ms | Allocations: 8872)

Hi @bassmans-check , thanks for reporting.
my first guess is that this is a problem with Ruby 3 that has not yet been addressed in foreman_salt. Not sure, though.

@evgeni Do you think this might be related to Ruby 3?

It could be, but hard to say w/o a test on EL8 with Foreman 3.10.

The error comes from this line:

So I’d argue it’s the environment name, not the state name that triggers this?
But that one is redacted in your output, so hard to debug.

2 Likes

My environments come from git and do indeed contain dashes and/or underscores… (forward-slashes do not work due to different errors, and have been circumvented at our end).
I could not find anything on valid characters for environments salt-wise, but would assume that, dashes and underscores should work, since they are valid characters in git.

Well, the above code validates them via /\A[\w\d.]+\z/, no idea whether this is a good validation or not, but that’s what foreman_salt does today (and has done for the last 10 years: fixes #8473 - import states and environments from master · theforeman/foreman_salt@d4ff701 · GitHub)

thanks. so we will have to find a workaround for the time being.

If I opened a ticket and PR to include -, that would probably not be backported to Foreman 3.10, right?

That’s for the foreman_salt maintainers (Hi @nadjaheitmann!) to decide :slight_smile:

I could not find anything on valid characters for environments salt-wise, but would assume that, dashes and underscores should work, since they are valid characters in git.

I did not find any information about that either. If dashes and underscores were not allowed, I would assume that it was written in a prominent way.

If I opened a ticket and PR to include -, that would probably not be backported to Foreman 3.10, right?

If you do, we can also backport it to 3.10 - it is the most recent Foreman version after all.

This was not the case in Foreman 3.9 on EL8.

So you did not have - and _ in your environment names, previously?

1 Like

@nadjaheitmann no, in 3.9 I was just importing regular wordchar-environments.

This time, since the server would be used for production, I wanted to introduce a multi-branch git-workflow, where developers would push changes to a ticket-named feature-branch (which becomes a saltenv due to gitfs in salt) and have that saltenv then testet on several servers before merging the feature branch into one of the more standard permanent ones like testing/staging/…

I will create a PR with ticket then, and see where this goes.

Thanks for your help and insights!

PR is here: Allow dashes in saltenv names by BigBadBassMan · Pull Request #202 · theforeman/foreman_salt · GitHub, added only the dash, as forward slashes work only on the salt side, not for foreman’s import.

2 Likes

Thanks @bassmans-check . Merged and released a new version. Once it is packaged, I will cherry-pick to Foreman 3.9 and 3.10 .

2 Likes

Packaging is done and cherry-picked to Foreman 3.9 and 3.10. Thanks @evgeni :slight_smile: Might take a while until repos are available I suppose.