Problem:
Create new hosts results in 422 “Audits is invalid”
**Expected outcome: **
New host should be created
Actual behaviour:
Host creation is reverted and the error “Audits is invalid” is created. This could occur several times. After a simple change in any subnet configuration the host gets created.
Foreman and Proxy versions:
Foreman 3.15, Foreman-proxies: 3.12
Foreman and Proxy plugin versions:
Distribution and version:
Rocky 9
Other relevant data:
The problem is resolved after changing a value in any subnet. It does not have to be the subnet which has been used for the creation of the affected host. It does not work if only the description of the subnet is changed. After the change is made to the subnet and host gets created but after some time the problem occurs again.
The solution which has been posted earlier to restore the database does not work for us because we had a migration to Foreman at the point the problem occured and we would have to add several hundreds of servers manually into Foreman.
production.log
2025-11-21T13:56:18 [I|aud|eac558ff] Host::Base (134752) create event on creator_id 442025-11-21T13:56:18 [W|app|eac558ff] Rolling back due to exception during save2025-11-21T13:56:18 [I|app|eac558ff] Backtrace for ‘Rolling back due to exception during save’ error (ActiveRecord::RecordInvalid): Validation failed: Audits is invalid
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:423:in `block in save_collection_association'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:401:in `each'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:401:in `save_collection_association'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:193:in `block in add_autosave_association_callbacks'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:166:in `instance_eval'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:166:in `block in define_non_cyclic_method'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:400:in `block in make_lambda'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:236:in `block in halting_and_conditional'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:599:in `block in invoke_after'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:599:in `each'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:599:in `invoke_after'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:108:in `run_callbacks'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:929:in `_run_create_callbacks'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/callbacks.rb:459:in `_create_record'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/timestamp.rb:108:in `_create_record'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/persistence.rb:1069:in `create_or_update'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/callbacks.rb:455:in `block in create_or_update'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
eac558ff | /usr/share/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/autosave_association.rb:370:in `around_save_collection_association'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:138:in `run_callbacks'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:929:in `_run_save_callbacks'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/callbacks.rb:455:in `create_or_update'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/timestamp.rb:126:in `create_or_update'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/persistence.rb:615:in `save'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/validations.rb:47:in `save'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/transactions.rb:298:in `block in save'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/transactions.rb:298:in `save'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/suppressor.rb:50:in `save'
eac558ff | /usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:148:in `create'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/abstract_controller/base.rb:215:in `process_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal/rendering.rb:165:in `process_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/abstract_controller/callbacks.rb:234:in `block in process_action'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
eac558ff | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/gems/gems/audited-5.8.0/lib/audited/sweeper.rb:16:in `around'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/gems/gems/audited-5.8.0/lib/audited/sweeper.rb:16:in `around'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:138:in `run_callbacks'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/abstract_controller/callbacks.rb:233:in `process_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal/rescue.rb:23:in `process_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/notifications.rb:206:in `block in instrument'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/notifications.rb:206:in `instrument'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal/instrumentation.rb:66:in `process_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
eac558ff | /usr/share/gems/gems/activerecord-7.0.8.7/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/abstract_controller/base.rb:151:in `process'
eac558ff | /usr/share/gems/gems/actionview-7.0.8.7/lib/action_view/rendering.rb:39:in `process'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal.rb:188:in `dispatch'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_controller/metal.rb:251:in `dispatch'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/routing/route_set.rb:32:in `serve'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/routing/mapper.rb:48:in `serve'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/journey/router.rb:50:in `block in serve'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/journey/router.rb:32:in `each'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/journey/router.rb:32:in `serve'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/routing/route_set.rb:852:in `call'
eac558ff | /usr/share/gems/gems/apipie-dsl-2.6.2/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
eac558ff | /usr/share/gems/gems/apipie-rails-1.4.2/lib/apipie/static_dispatcher.rb:74:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/static.rb:23:in `call'
eac558ff | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
eac558ff | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
eac558ff | /usr/share/gems/gems/apipie-rails-1.4.2/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/tempfile_reaper.rb:15:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/etag.rb:27:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/conditional_get.rb:40:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/head.rb:12:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/http/permissions_policy.rb:38:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/http/content_security_policy.rb:39:in `call'
eac558ff | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/session/abstract/id.rb:266:in `context'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/session/abstract/id.rb:260:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/cookies.rb:704:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:99:in `run_callbacks'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/show_exceptions.rb:29:in `call'
eac558ff | /usr/share/gems/gems/railties-7.0.8.7/lib/rails/rack/logger.rb:40:in `call_app'
eac558ff | /usr/share/gems/gems/railties-7.0.8.7/lib/rails/rack/logger.rb:27:in `call'
eac558ff | /usr/share/gems/gems/sprockets-rails-3.5.2/lib/sprockets/rails/quiet_assets.rb:17:in `call'
eac558ff | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/request_id.rb:26:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/method_override.rb:24:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/runtime.rb:22:in `call'
eac558ff | /usr/share/gems/gems/activesupport-7.0.8.7/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/executor.rb:14:in `call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/sendfile.rb:110:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/ssl.rb:77:in `call'
eac558ff | /usr/share/gems/gems/actionpack-7.0.8.7/lib/action_dispatch/middleware/host_authorization.rb:131:in `call'
eac558ff | /usr/share/gems/gems/secure_headers-7.1.0/lib/secure_headers/middleware.rb:11:in `call'
eac558ff | /usr/share/gems/gems/railties-7.0.8.7/lib/rails/engine.rb:530:in `call'
eac558ff | /usr/share/gems/gems/railties-7.0.8.7/lib/rails/railtie.rb:226:in `public_send'
eac558ff | /usr/share/gems/gems/railties-7.0.8.7/lib/rails/railtie.rb:226:in `method_missing'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/urlmap.rb:74:in `block in call'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/urlmap.rb:58:in `each'
eac558ff | /usr/share/gems/gems/rack-2.2.14/lib/rack/urlmap.rb:58:in `call'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/configuration.rb:279:in `call'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/request.rb:99:in `block in handle_request'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/thread_pool.rb:390:in `with_force_shutdown'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/request.rb:98:in `handle_request'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/server.rb:472:in `process_client'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/server.rb:254:in `block in run'
eac558ff | /usr/share/gems/gems/puma-6.6.0/lib/puma/thread_pool.rb:167:in `block in spawn_thread'