Jira (FACT-2998) CLI breaks when querying for custom facts

4 views
Skip to first unread message

Gheorghe Popescu (Jira)

unread,
Mar 26, 2021, 9:12:04 AM3/26/21
to puppe...@googlegroups.com
Gheorghe Popescu created an issue
 
Facter / Bug FACT-2998
CLI breaks when querying for custom facts
Issue Type: Bug Bug
Affects Versions: FACT 4.0.52
Assignee: Unassigned
Created: 2021/03/26 6:11 AM
Priority: Normal Normal
Reporter: Gheorghe Popescu

When you query for a custom structured fact, Facter uses Hash#dig to cicle through keys, but this can fail if the value of one of the cicled keys is not a Hash.

Simple ruby example:

❯ ruby -e '{"a" => "b"}.dig("a", "z")'
Traceback (most recent call last):
	1: from -e:1:in `<main>'
-e:1:in `dig': String does not have #dig method (TypeError)

Steps to reproduce in Facter:
1. create a custom fact

Facter.add('foo.bar') do
  setcode { 'baz' }
end

Query for that fact name and an extra key:

❯ bx facter foo.bar.x
 
facter-4.0.52/lib/facter/framework/formatters/formatter_helper.rb:28:in `dig': String does not have #dig method (TypeError)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages