Jira (FACT-1902) Facter should validate that external/custom/executable facts output proper UTF-8

8 views
Skip to first unread message

Branan Riley (JIRA)

unread,
Jan 2, 2019, 6:30:10 PM1/2/19
to puppe...@googlegroups.com
Branan Riley created an issue
 
Facter / Improvement FACT-1902
Facter should validate that external/custom/executable facts output proper UTF-8
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2019/01/02 3:29 PM
Priority: Normal Normal
Reporter: Branan Riley

Modern versions of Puppet require that the data they serialize to JSON is proper UTF-8. When facts have an incorrect encoding, this currently does not raise an error until it is serialized, at which point it is far too late, and the error message is not helpful.

Instead, Facter itself should raise an error about this, indicating the specific fact which returned bad data. This will provide better context for

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Charlie Sharpsteen (JIRA)

unread,
Jan 3, 2019, 12:59:03 PM1/3/19
to puppe...@googlegroups.com
Charlie Sharpsteen updated an issue
Change By: Charlie Sharpsteen
Modern versions of Puppet require that the data they serialize to JSON is proper UTF-8. When facts have an incorrect encoding, this currently does not raise an error until it is serialized, at which point it is far too late, and the error message is not helpful.

Instead, Facter itself should raise an error about this, indicating the specific fact which returned bad data. This will provide better context for debugging.

Charlie Sharpsteen (JIRA)

unread,
Jan 3, 2019, 1:10:03 PM1/3/19
to puppe...@googlegroups.com

Scott McClellan (JIRA)

unread,
Jan 7, 2019, 2:11:05 PM1/7/19
to puppe...@googlegroups.com

Adam Bottchen (JIRA)

unread,
Feb 14, 2019, 7:07:03 PM2/14/19
to puppe...@googlegroups.com

Adam Bottchen (JIRA)

unread,
Feb 14, 2019, 7:12:03 PM2/14/19
to puppe...@googlegroups.com

Adam Bottchen (JIRA)

unread,
Feb 14, 2019, 7:13:03 PM2/14/19
to puppe...@googlegroups.com

Charlie Sharpsteen (JIRA)

unread,
Apr 10, 2019, 4:37:03 PM4/10/19
to puppe...@googlegroups.com
Charlie Sharpsteen commented on Improvement FACT-1902
 
Re: Facter should validate that external/custom/executable facts output proper UTF-8

We should also validate that fact output does not contain null characters in addition to being valid UTF-8. This is because Postgres rejects any strings that include nulls.

Charlie Sharpsteen (Jira)

unread,
Jul 15, 2020, 11:42:03 AM7/15/20
to puppe...@googlegroups.com

This also came up today in community slack where a windows user couldn't get a catalog due some fact not producing UTF-8 data. Without this sort of checking in Facter, it is very difficult to determine which fact is the problem.

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

Josh Cooper (Jira)

unread,
Jan 26, 2021, 12:49:03 PM1/26/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 26, 2021, 12:53:03 PM1/26/21
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Jan 27, 2021, 4:50:03 AM1/27/21
to puppe...@googlegroups.com

Josh Cooper yes, Facter 4 does the validation

e.g.
a custom facts with a invalid UTF-8 result

Facter.add(:my_custom_fact) do
  setcode do
    "\xc3\x28"
  end
end

will give

[2021-01-27 11:42:10.579028 ] ERROR Facter - Fact resolution fact='my_custom_fact', resolution='<anonymous>' resolved to an invalid value: String "\xC3(" doesn't match the reported encoding UTF-8 

 and the value of the fact will not be reported along with the other facts. 

The validation is done for custom and external facts (executable facts are external facts as well).

 

Facter 3 does not seam to validate the results.

e.g.

Same external facts and Facter 3 reports

my_custom_fact => �(

Reply all
Reply to author
Forward
0 new messages