Foreman Client Registration error " HTTP error (422 - Unknown): Validation failed: Name must match regex /^[a-zA-Z0-9\-_]+$/ "

Problem: I’m trying to register an RHEL7 machine to our Foreman Katello Server. Which is on the same network. While registering via subscription manager i get the below error message.
#subscription-manager register --org=“Orgname” --activationkey=“RHEL 7”

HTTP error (422 - Unknown): Validation failed: Name must match regex /^[a-zA-Z0-9-_]+$/

Expected outcome: It should register to the Foreman server. but it throws error. only on this particular server i have issue, rest all other RHEL 7 servers are registering without any issues.

Foreman and Proxy versions: Version 1.22.0 (this is not a proxy server)

Foreman and Proxy plugin versions: Version 1.22.0 (this is not a proxy server)

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)

logs

It seems that the server has an invalid hostname. Check the output of hostname -f - are there any characters there that are not permitted for host names? (English characters, numbers and dashes)

the server hase FQDN hostname, did check on that and there are not Special character too.
hostname -f
sesklgdsadv01.emea.xxxxxxxxxx.net (Removed Domain name)

Uh, wait a sec…

So, hostname -f returns “sesklgdsadv01.emea.xxxxxxxxxx.net”.
The regex is “/^[a-zA-Z0-9-_]+$/”.

I’d expect the regex to not match due to the period separators. The regex will only match upper case and lower case alphabetics, digits, and “-” and “_”. I don’t see a period in the class.

This is interesting:

[~]$ echo "sesklgdsadv01.emea.xxxxxxxxxx.net" | egrep -c "^[a-zA-Z0-9-_]+$"
grep: Invalid range end
[~]$ echo "sesklgdsadv01.emea.xxxxxxxxxx.net" | egrep -c "^[a-zA-Z0-9_-]+$"
0

The regex would appear to me to want to match a bare hostname, not a fully qualified hostname. And depending on what regex library is actually in use, it may be covering up some other issue.

1 Like

Fixed that issue.
Under Administrator → Settings → ForemanHostExtraValidator →
I removed the Values in “host_name_validation_regex” and just added empty.

and then re-tried and it worked. :slight_smile:

Earlier in that Field it had “/[1]+$/”. Now it is empty.


  1. a-zA-Z0-9-_ ↩︎

Now you have me curious, as I don’t even have that tab under Administration/Settings.

Foreman 1.21.3-1
Katello 3.11.1-1

Any idea what provides that tab?

A quick Internet search for ForemanHostExtraValidator is pretty much limited to https://github.com/theforeman/foreman_host_extra_validator and that’s 4 years old.

And with a quick update to Foreman 1.22.0 and Katello 3.12.0, I’m still not finding that setting.

Pretty sure @aswath2saru has that plugin installed.
I don’t think that is a katello default plugin. Also, it is not 4 years old, but instead the last commit as well as the last (and only) version was August 2018.
If you want that functionality, you could probably install the plugin, but it does look somewhat unmaintained (maybe due to the fact it did not need updates in that last year). Maybe @TimoGoebel can answer whether it is abandonware or just did not need updates?

i use the latest foreman and i added the host validation plugin.
please find the installation steps i did.

foreman-installer --scenario katello --foreman-initial-admin-password=XXXXXXX
–foreman-initial-organization XXXXXXXXXXXXX
–katello-proxy-url http://XXXXXXXXXXXXXXXXX
–katello-proxy-port XXXXXXXXXXXX
–foreman-initial-location Americas
–enable-foreman-plugin-ansible
–enable-foreman-plugin-discovery
–enable-foreman-plugin-hooks
–enable-foreman-plugin-bootdisk
–enable-foreman-plugin-default-hostgroup
–enable-foreman-plugin-setup
–enable-foreman-plugin-openscap
–enable-foreman-plugin-remote-execution
–enable-foreman-plugin-tasks
–enable-foreman-plugin-templates
–enable-foreman-plugin-kubevirt
–enable-foreman-plugin-hooks
–enable-foreman-plugin-salt
–enable-foreman-plugin-snapshot-management
–enable-foreman-cli
–enable-foreman-cli-tasks
–enable-foreman-cli-remote-execution
–enable-foreman-compute-openstack
–enable-foreman-compute-vmware
–enable-foreman-compute-ovirt
–enable-foreman-cli-kubevirt
–enable-foreman-compute-ec2
–enable-foreman-compute-gce
–enable-foreman-compute-libvirt -vvvv

It should work fine. If it does not, please open an issue in the repo and I’ll see to it that it gets fixed. If somebody wants to help maintaining it, let me know. :slight_smile:

1 Like

Mea culpa… I was looking at the wrong dates.

Still… if I am looking at the README right, it’s entire purpose is to use a regex to validate hostnames. If @aswath2saru has removed the regex completely, then the plugin doesn’t provide any [immediate] value.

1 Like