Bug #28563
undefined method `split' for nil:NilClass when viewing the host info with hammer
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1736809
Description of problem:
hammer -u admin -p redhat host info --name=example.com failed with below error found in the production.log
ActionView::Template::Error: undefined method `split' for nil:NilClass
/usr/share/foreman/app/models/nic/base.rb:90:in `type_name'
/usr/share/foreman/app/views/api/v2/interfaces/main.json.rabl:9:in `block in eval_source'
/opt/theforeman/tfm/root/usr/share/gems/gems/rabl-0.13.1/lib/rabl/builder.rb:152:in `node'
/opt/theforeman/tfm/root/usr/share/gems/gems/rabl-0.13.1/lib/rabl/builder.rb:114:in `block in compile_settings'
/opt/theforeman/tfm/root/usr/share/gems/gems/rabl-0.13.1/lib/rabl/builder.rb:113:in `each'
This is due to one interface on the host is having nil type. However, this is working in 6.4 so it seems like a regression..
Version-Release number of selected component (if applicable):
6.5
How reproducible:
Easy
Steps to Reproduce:
1. hack the db to update an interface's type to nil
2. use hammer to list host info
Actual results:
Hammer command doesn't work and same as the WebUI.
Expected results:
Both hammer and WebUI should work.
Additional info:
We have a KCS for this issue. However, I think satellite should be smart enough to use the default type for an interface with nil type..
Associated revisions
History
#1
Updated by The Foreman Bot over 2 years ago
- Assignee set to Tomer Brisker
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/7287 added
#2
Updated by The Foreman Bot over 2 years ago
- Fixed in Releases 2.0.0 added
#3
Updated by Tomer Brisker over 2 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset 65f194f5ae14688a1fa78c476ec2ea6694740aba.
#4
Updated by Tomer Brisker over 2 years ago
- Fixed in Releases 1.24.1 added
Fixes #28563 - Be defensive about interface type in API
It appears in some cases interfaces might be registered in the database
with `nil` type. While that is invalid, such interface's existance
causes the host/nic APIs to return an error instead of the requested
information.
This PR makes sure that such interfaces are still displayed in the API.