Cannot re-register existing host

We are running Foreman 3.19.1 / Katello 4.21.0 with RHEL hosts. We do not use Foreman provisioning facilities, but register existing hosts with Foreman.

We are encountering an issue when attempting to re-register an already registered host using the standard curl | bash command generated via the Foreman Web UI (Hosts β†’ Register Host).

The initial registration of a previously unknown host works perfectly. However, running the registration command a second time on the same host fails at the very final step when reporting the build status to the /unattended/built endpoint with a 404 error.

Registration Command Used

curl 'https://smartproxy.query.local.consul.example.com:9090/register?activation_keys=rhel9-dev&download_utility=curl&force=true&location_id=3&organization_id=1&update_packages=false' \
--header 'Authorization: Bearer <TOKEN>' | bash

The following error can be seen in /var/log/foreman/production.log:

2026-08-16T21:46:18 [I|app|0d492957] Started GET "/unattended/built?token=[redacted]&url=http%3A%2F%2Fsmartproxy1.example.com%3A8000" for 192.168.0.3 at 2026-08-16 21:46:18 +0300
2026-08-16T21:46:18 [I|app|0d492957] Processing by UnattendedController#built as TEXT
2026-08-16T21:46:18 [I|app|0d492957]   Parameters: {"token"=>"[redacted]", "url"=>"http://smartproxy1.example.com:8000", "unattended"=>{}}
2026-08-16T21:46:18 [E|app|0d492957] unattended: unable to find a host that matches the request from 192.168.0.3. Search paths: token: [redacted]
2026-08-16T21:46:18 [I|app|0d492957]   Rendered text template (Duration: 0.0ms | Allocations: 2)
2026-08-16T21:46:18 [I|app|0d492957] Completed 404 Not Found in 11ms (Views: 2.9ms | ActiveRecord: 3.1ms | Allocations: 2792)

Tracing back a second earlier revealed that it cannot enter a build state.

2026-08-16T21:46:17 [I|app|62b051d1] Started POST "/register?url=https%3A%2F%2Fsmartproxy.query.local.consul.example.com%3A9090" for
 192.168.0.3 at 2026-08-16 21:46:17 +0300
2026-08-16T21:46:17 [I|app|62b051d1] Processing by Api::V2::RegistrationController#host as HTML
2026-08-16T21:46:17 [I|app|62b051d1]   Parameters: {"uuid"=>"f16f901d-878c-4973-a0e2-39fe9b4f8bfa", "host"=>{"build"=>"false", "organization_id
"=>"1", "location_id"=>"3"}, "update_packages"=>"false", "url"=>"https://smartproxy.query.local.consul.example.com:9090"}
2026-08-16T21:46:17 [I|app|62b051d1] Authorized user admin(Admin User)
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (371) destroy event on name host_update_packages
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (371) destroy event on value false
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (371) destroy event on reference_id 343
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (371) destroy event on hidden_value false
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (371) destroy event on key_type boolean
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (372) create event on name host_update_packages
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (372) create event on value false
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (372) create event on reference_id 343
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (372) create event on hidden_value false
2026-08-16T21:46:17 [I|aud|62b051d1] Parameter (372) create event on key_type boolean
2026-08-16T21:46:17 [W|app|62b051d1] Not queueing Host::Managed: ["Host parameters is invalid"]
2026-08-16T21:46:17 [W|app|62b051d1] Not queueing Host::Managed: ["Host parameters is invalid"]
2026-08-16T21:46:17 [W|app|62b051d1] Not queueing Host::Managed: ["Host parameters is invalid"]
2026-08-16T21:46:17 [W|app|62b051d1] Set build failed: #<ActiveModel::Errors [#<ActiveModel::Error attribute=host_parameters, type=invalid, opt
ions={:value=>#<ActiveRecord::Associations::CollectionProxy [#<HostParameter id: 371, name: "host_update_packages", value: [FILTERED], referenc
e_id: 343, created_at: "2026-08-16 18:45:49.792499000 +0000", updated_at: "2026-08-16 18:45:49.792499000 +0000", type: "HostParameter", priorit
y: 70, hidden_value: [FILTERED], key_type: "boolean", searchable_value: [FILTERED]>]>}>]>

It attempts to destroy and recreate the host_update_packages boolean parameter, and then complains that this parameter is invalid.

Workarounds Found

We can successfully re-register the host if we do either of the following:

  1. Manually delete the host_update_packages parameter from the host in the Foreman UI before running the command.

  2. Manually strip out the &update_packages=false argument from the generated curl URL.

Because the Foreman UI automatically appends the &update_packages argument to the generated registration string by default, this effectively breaks re-registration out-of-the-box for existing hosts.

Is this a known bug, or is there a configuration adjustment we are missing?

Thanks for providing the detailed logs and the workarounds.

From the logs, it looks like the failure is happening while Foreman tries to update the existing host_update_packages host parameter during re-registration. The parameter is first deleted and then recreated with false, but Foreman considers the host parameters invalid and fails to set the build state. The later /unattended/built 404 appears to be a consequence of this failure.

Since removing host_update_packages or removing update_packages=false from the registration command allows re-registration to succeed, this looks like a potential Foreman bug rather than a configuration issue.

Could you check if the same behavior occurs with another already-registered host? If so, I think this would be useful to reproduce and report upstream, including the production.log entries and the exact registration command.

For now, removing update_packages=false from the registration command appears to be a reasonable workaround if package updating is not required.

From a QE point of view, my understanding is that re-registration of an existing/known host fails when update_packages=false is used during registration. Is that correct?

I can confirm that the problem reproduces at will with other hosts.

Could you please clarify what the number in brackets means in Parameter (372) ?

I am not very familiar with Ruby, but it looks like the process deleted host_update_packages with ID 371 and re-created it with ID 372. However, the error message still references the deleted ID 371 (as seen in #<HostParameter id: 371).

Does this interpretation make sense?

Exactly. Removing update_packages=false from the curl command allows the host to re-register successfully. However, Foreman includes this parameter by default.

Yes, your interpretation of the numbers is correct. 371 and 372 are the database IDs of the HostParameter records. The log shows that Foreman destroys the existing host_update_packages parameter (ID 371) and then creates a new one (ID 372).

I think I have pinpointed the bug and opened a Redmine issue and a PR to fix it:

Please don’t judge too harshly, as this is my very first time working with Ruby!

Any feedback on the PR is highly appreciated.

Hey @gtrenin Could you please share redmine issue link as well ?

@vijaysawant

I suppose its this one.