Bug #39225
openKeyError (key{package} not found) showing up in the logs preventing hosts (and other stuff) from being shown on the foreman UI after a server reboot
Description
Fresh foreman install, I restarted the server and now cannot see the host list (server error 500).
Logs show this:
2026-04-10T15:01:56 [F|app|060ee4ec]
060ee4ec | KeyError (key{package} not found):
060ee4ec |
060ee4ec | config/initializers/apipie.rb:69:in `%'
060ee4ec | config/initializers/apipie.rb:69:in `block (4 levels) in <top (required)>'
060ee4ec | config/initializers/apipie.rb:69:in `block (3 levels) in <top (required)>'
060ee4ec | lib/foreman/middleware/logging_context_session.rb:22:in `call'
060ee4ec | lib/foreman/middleware/logging_context_request.rb:11:in `call'
We're about to rollout Foreman on a big department and I can't showcase it until this is resolved. please please please help!
Files
Updated by Jakub Duchek 4 months ago
Hi,
Thanks for the report. Looking at config/initializers/apipie.rb:69, that line runs all apipie doc strings through _(str) % substitutions, where substitutions is a hash defined a few lines above containing only these keys: operatingsystem_families, providers, providers_requiring_url, default_nic_type, template_kinds, host_rebuild_steps. There's no package key.
So the KeyError (key{package} not found) means that somewhere - most likely in a plugin - there's an apipie description/param string that contains a placeholder, but nothing ever registers a package substitution. When that string gets translated on the first request that hits the endpoint, Ruby's String# blows up and the whole response turns into a 500.
To narrow it down, could you share a bit more detail?
Is this really a plain Foreman install, or do you have any plugins installed (Katello, Remote Execution, Ansible, Discovery, ...)? foreman-rake plugin:list output would be perfect. The package wording strongly suggests Katello or a content-management plugin.
Foreman version and plugin versions (rpm -qa | grep -E 'foreman|katello|tfm' or the equivalent for your distro).
Which URL triggers the 500? The stack trace you pasted is truncated at the apipie initializer - the full trace with the controller/action on top would help pinpoint the endpoint whose doc string contains %{package}.
Does it happen only in a non-English locale, or also with Accept-Language: en? The failure is inside FastGettext.with_locale(loc), so it may only reproduce when the translation of a string introduces the %{package} placeholder while the English original doesn't.
If you can, run this on the server and paste the output - it will point straight at the culprit:
grep -rn '%{package}' /usr/share/foreman/ /usr/share/gems/gems/ 2>/dev/null
(adjust paths to wherever Foreman and its gems live on your system)
6. Does restarting Foreman (foreman-maintain service restart or systemctl restart foreman) change anything, or is the 500 reproducible on every single request to that page?