Jira (FACT-2919) Aggregate facts are broken

28 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Jan 14, 2021, 7:24:03 PM1/14/21
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Facter / Bug FACT-2919
Aggregate facts are broken
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/01/14 4:23 PM
Priority: Normal Normal
Reporter: Josh Cooper

Commit d48c237c added debugging but broke aggregate fact handling. To reproduce:

$ mkdir facts
$ cat > facts/agg.rb <<EOF
Facter.add(:foo, :type => :aggregate) do
    chunk :first do
        ['foo']
    end
 
    chunk :second do
        ['bar']
    end
end
END
$ bx facter --custom-dir `pwd`/facts foo
bundler: failed to load command: facter (/Users/josh/work/facter/.bundle/ruby/2.5.0/bin/facter)
Traceback (most recent call last):
	39: from /usr/local/opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>'
        ...
	16: from /Users/josh/work/facter/lib/facter/framework/cli/cli.rb:114:in `query'
	15: from /Users/josh/work/facter/lib/facter.rb:414:in `to_user_output'
	14: from /Users/josh/work/facter/lib/facter.rb:473:in `resolve_facts_for_user_query'
	13: from /Users/josh/work/facter/lib/facter/framework/core/fact_manager.rb:25:in `resolve_facts'
	12: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:7:in `resolve_facts'
	11: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:19:in `external_facts'
	10: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:19:in `each'
	 9: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:21:in `block in external_facts'
	 8: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:121:in `value'
	 7: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:167:in `searching'
	 6: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:124:in `block in value'
	 5: from /Users/josh/work/facter/lib/facter/framework/benchmarking/timer.rb:18:in `measure'
	 4: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:125:in `block (2 levels) in value'
	 3: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:199:in `find_first_real_value'
	 2: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:199:in `each'
	 1: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:208:in `block in find_first_real_value'
/Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:217:in `log_fact_path': undefined method `source_location' for nil:NilClass (NoMethodError)

Also I noticed that 4.x facter does not accept a relative custom dir:

$ bx facter --custom-dir facts foo
Excluding facts from search path. Fact file paths must be an absolute directory

But 3.x facter does, is the facter 4 behavior intentional?

[root@aural-heater ~]# facter --custom-dir facts/ foo
[
  "foo",
  "bar"
]

It took me a little while to reproduce the problem because the docs for aggregate facts show each chunk returning a string, but it needs to be an array or hash:

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Jan 14, 2021, 7:25:03 PM1/14/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: FACT 4.0.49

Josh Cooper (Jira)

unread,
Jan 14, 2021, 7:25:04 PM1/14/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Priority: Normal Major

Josh Cooper (Jira)

unread,
Jan 14, 2021, 7:25:04 PM1/14/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Affects Version/s: FACT 4.0.48

Gheorghe Popescu (Jira)

unread,
Jan 15, 2021, 5:21:04 AM1/15/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Jan 15, 2021, 8:36:03 AM1/15/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes: Bug Fix
Release Notes Summary: Fixed a bug where facter was breaking when trying to add a debug message for the location where an aggregate facts is resolved from. This only happed for aggregate facts that return an array or hash, without having an aggregate block call.

Gheorghe Popescu (Jira)

unread,
Jan 15, 2021, 8:49:04 AM1/15/21
to puppe...@googlegroups.com
Gheorghe Popescu assigned an issue to Gheorghe Popescu
Change By: Gheorghe Popescu
Assignee: Gheorghe Popescu
Reply all
Reply to author
Forward
0 new messages