Jira (FACT-3123) CEM Bug Template

70 views
Skip to first unread message

Björn Lässig

unread,
May 24, 2022, 6:31:03 AM5/24/22
to puppe...@googlegroups.com
Björn Lässig created an issue
 
Facter / Bug FACT-3123
CEM Bug Template
Issue Type: Bug Bug
Affects Versions: FACT 4.2.6
Assignee: Unassigned
Components: Facter 4, QA
Created: 2022/05/24 3:30 AM
Priority: Major Major
Reporter: Björn Lässig

Who found the bug?

I found the bug

Where was the bug found?

  • System: Fedora Core
  • Version: 36
  • Operating system(s): fedora core 36
  • Puppet version: not installed

What is malfunctioning?

Custom facts in /etc/facter/facts.d that return valid json or yaml are ignored with debug message:

```

DEBUG Facter - Could not parse executable fact output as YAML or JSON (wrong number of arguments (given 2, expected 1)) 

Use this Test fact in /etc/facter/facts.d/test.py:

#! /usr/bin/env python3
print('{"foobar": 23}')

 

/etc/facter/facts.d/test.py | json_verify 
JSON is valid

 

# facter -d foobar
[2022-05-24 12:19:05.899944 ] INFO Facter - executed with command line: -d foobar 
[2022-05-24 12:19:05.900013 ] DEBUG Facter - Facter version: 4.2.6 
[2022-05-24 12:19:05.900106 ] DEBUG Facter::ClassDiscoverer - There is no module named Fedora 
[2022-05-24 12:19:05.902326 ] DEBUG Facter::FactManager - Resolving facts sequentially 
[2022-05-24 12:19:05.902462 ] DEBUG Facter::FactLoader - Loading all internal facts 
[2022-05-24 12:19:05.902564 ] DEBUG Facter::FactLoader - Loading custom facts 
[2022-05-24 12:19:05.903564 ] DEBUG Facter::FactLoader - Loading external facts 
[2022-05-24 12:19:05.903836 ] DEBUG Facter::Core::Execution::Posix - Executing command: /etc/facter/facts.d/test.py 
[2022-05-24 12:19:05.919108 ] DEBUG Facter - Could not parse executable fact output as YAML or JSON (wrong number of arguments (given 2, expected 1)) 
[2022-05-24 12:19:05.919309 ] DEBUG LegacyFacter::Util::DirectoryLoader - Fact file /etc/facter/facts.d/test.py was parsed but no key=>value data was returned 
[2022-05-24 12:19:05.993976 ] DEBUG Facter::LegacyFactFormatter - Formatting for single user query 
[2022-05-24 12:19:05.994074 ] DEBUG Facter::LegacyFactFormatter - Remove quotes from value if it is a simple string 

 

What does success look like?

facter -d foobar[2022-05-24 12:22:02.893574 ] INFO Facter - executed with command line: -d foobar [2022-05-24 12:22:02.893824 ] DEBUG Facter - Facter version: 4.2.6 [2022-05-24 12:22:02.893891 ] DEBUG Facter::ClassDiscoverer - There is no module named Fedora [2022-05-24 12:22:02.896250 ] DEBUG Facter::FactManager - Resolving facts sequentially [2022-05-24 12:22:02.896355 ] DEBUG Facter::FactLoader - Loading all internal facts [2022-05-24 12:22:02.896464 ] DEBUG Facter::FactLoader - Loading custom facts [2022-05-24 12:22:02.897408 ] DEBUG Facter::FactLoader - Loading external facts [2022-05-24 12:22:02.897680 ] DEBUG Facter::Core::Execution::Posix - Executing  command: /etc/facter/facts.d/test.py{}[2022-05-24 12:22:02.987198 ] DEBUG Facter::QueryParser - List of resolvable facts: [#<Facter::SearchedFact:0x00007f40364c3da8 @name="foobar", @fact_class=nil, @user_query="foobar", @type=:external, @file="/etc/facter/facts.d/test.py">] 
[2022-05-24 12:22:02.987445 ] DEBUG Facter::Util::Fact - external fact foobar got resolved from: /etc/facter/facts.d/test.py 
[2022-05-24 12:22:02.987544 ] DEBUG Facter::FactManager - fact "foobar" has resolved to: 23 
[2022-05-24 12:22:02.987678 ] DEBUG Facter::LegacyFactFormatter - Formatting for single user query 
[2022-05-24 12:22:02.987766 ] DEBUG Facter::LegacyFactFormatter - Converting hash to pretty json 
[2022-05-24 12:22:02.987820 ] DEBUG Facter::LegacyFactFormatter - Change key value delimiter from : to => 
[2022-05-24 12:22:02.987846 ] DEBUG Facter::LegacyFactFormatter - Remove quotes from parent nodes 
[2022-05-24 12:22:02.987866 ] DEBUG Facter::LegacyFactFormatter - Remove double backslashes from paths 
[2022-05-24 12:22:02.987881 ] DEBUG Facter::LegacyFactFormatter - Remove quotes from value if it is a simple string 
23

 

Fixed for me:

+++ b/usr/share/gems/gems/facter-4.2.6/lib/facter/custom_facts/util/parser.rb
@@ -70,7 +70,7 @@ module LegacyFacter
         def parse_executable_output(output)
           res = nil
           begin
-            res = YAML.safe_load(output, [Symbol, Time])
+            res = YAML.safe_load(output, permitted_classes:[Symbol, Time])
           rescue StandardError => e
             Facter.debug("Could not parse executable fact output as YAML or JSON (#{e.message})")
           end

 

This Jira - userinterface is really a hell.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Björn Lässig

unread,
May 24, 2022, 6:33:03 AM5/24/22
to puppe...@googlegroups.com
Björn Lässig updated an issue
Change By: Björn Lässig
h2. Who found the bug?

I found the bug
h2. Where was the bug found?
* System: Fedora Core
* Version: 36
* Operating system(s): fedora core 36
* Puppet version: not installed

h2. What is malfunctioning?


Custom facts in /etc/facter/facts.d that return valid json or yaml are ignored with debug message:

```

DEBUG Facter - Could not parse executable fact output as YAML or JSON (wrong number of arguments (given 2, expected 1)) 

Use this Test fact in /etc/facter/facts.d/test.py:

{{#! /usr/bin/env python3}}
{{print('\{"foobar": 23}')}}

 

{{/etc/facter/facts.d/test.py | json_verify }}
{{JSON is valid}}

 

{{# facter -d foobar}}
{{[2022-05-24 12:19:05.899944 ] INFO Facter - executed with command line: -d foobar }}
{{[2022-05-24 12:19:05.900013 ] DEBUG Facter - Facter version: 4.2.6 }}
{{[2022-05-24 12:19:05.900106 ] DEBUG Facter::ClassDiscoverer - There is no module named Fedora }}
{{[2022-05-24 12:19:05.902326 ] DEBUG Facter::FactManager - Resolving facts sequentially }}
{{[2022-05-24 12:19:05.902462 ] DEBUG Facter::FactLoader - Loading all internal facts }}
{{[2022-05-24 12:19:05.902564 ] DEBUG Facter::FactLoader - Loading custom facts }}
{{[2022-05-24 12:19:05.903564 ] DEBUG Facter::FactLoader - Loading external facts }}
{{[2022-05-24 12:19:05.903836 ] DEBUG Facter::Core::Execution::Posix - Executing command: /etc/facter/facts.d/test.py }}
{{[2022-05-24 12:19:05.919108 ] DEBUG Facter - Could not parse executable fact output as YAML or JSON (wrong number of arguments (given 2, expected 1)) }}
{{[2022-05-24 12:19:05.919309 ] DEBUG LegacyFacter::Util::DirectoryLoader - Fact file /etc/facter/facts.d/test.py was parsed but no key=>value data was returned }}
{{[2022-05-24 12:19:05.993976 ] DEBUG Facter::LegacyFactFormatter - Formatting for single user query }}
{{[2022-05-24 12:19:05.994074 ] DEBUG Facter::LegacyFactFormatter - Remove quotes from value if it is a simple string }}

 
h2. What does success look like?

{{
{} facter -d foobar { }} }

Björn Lässig

unread,
May 24, 2022, 6:35:02 AM5/24/22
to puppe...@googlegroups.com
Fixed Fix for me:


{{+++ b/usr/share/gems/gems/facter-4.2.6/lib/facter/custom_facts/util/parser.rb}}
{{@@ -70,7 +70,7 @@ module LegacyFacter}}
{{         def parse_executable_output(output)}}
{{           res = nil}}
{{           begin}}
{{-            res = YAML.safe_load(output, [Symbol, Time])}}
{{+            res = YAML.safe_load(output, permitted_classes:[Symbol, Time])}}
{{           rescue StandardError => e}}
{{             Facter.debug("Could not parse executable fact output as YAML or JSON (#\{e.message})")}}
{{           end}}

 

{{This Jira - userinterface is really a hell.}}

Björn Lässig

unread,
May 24, 2022, 6:39:01 AM5/24/22
to puppe...@googlegroups.com
Björn Lässig commented on Bug FACT-3123
 
Re: CEM Bug Template

https://github.com/ruby/psych/issues/533

this is probably the bug in rubygem-psych.x86_64    (Version here  4.0.3-164.fc36) that created this.

Nirupama Mantha (Jira)

unread,
May 24, 2022, 4:13:03 PM5/24/22
to puppe...@googlegroups.com
Nirupama Mantha updated an issue
Change By: Nirupama Mantha
Component/s: QA
Reply all
Reply to author
Forward
0 new messages