Project

General

Profile

Bug #28563

undefined method `split' for nil:NilClass when viewing the host info with hammer

Added by Tomer Brisker 4 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Inventory
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

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

Revision 65f194f5 (diff)
Added by Tomer Brisker 4 months ago

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.

History

#1 Updated by The Foreman Bot 4 months 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 4 months ago

  • Fixed in Releases 2.0.0 added

#3 Updated by Tomer Brisker 4 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by Tomer Brisker 3 months ago

  • Fixed in Releases 1.24.1 added

Also available in: Atom PDF