Jira (FACT-3068) Facter timezone utf8 problem

33 views
Skip to first unread message

Dominique Arpin (Jira)

unread,
Aug 27, 2021, 7:38:03 AM8/27/21
to puppe...@googlegroups.com
Dominique Arpin created an issue
 
Facter / Bug FACT-3068
Facter timezone utf8 problem
Issue Type: Bug Bug
Affects Versions: FACT 3.9.z
Assignee: Unassigned
Components: Facter 3
Created: 2021/08/27 4:37 AM
Priority: Normal Normal
Reporter: Dominique Arpin

Hi,

I got a utf8 problem after upgrading from puppet 6.24.0 (opensource) to 7.9 or 7.10.

Puppet 6.24.0 (facter -j)
"timezone": "Est (heure dÆÚtÚ)",
 
Puppet 7.10.0 (facter -j)
"timezone": "Est (heure d?été)",
I got a direct impact when you use Ansible (2.9):

{ "exception": "C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.7.0/json/common.rb:286:in `to_json': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)\r\nAu caractère Ligne:243 : 9\r\n+ &facter -j | Tee-Object -Variable facter_output > $null\r\n+ ~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (C:/Program File...GeneratorError):String) [], RemoteException\r\n + FullyQualifiedErrorId : NativeCommandError\r\n\r\nScriptStackTrace:\r\nà <ScriptBlock>, <Aucun fichier> : ligne 243\r\n", "msg": "Unhandled exception while executing module: C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/2.7.0/json/common.rb:286:in `to_json': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)", "_ansible_verbose_override": true, "_ansible_no_log": false, "changed": false }

Regards,

Dominique

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Aug 30, 2021, 5:31:02 PM8/30/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-3068
 
Re: Facter timezone utf8 problem

Dominique Arpin what is the output of:

C:\>"C:\Program Files\Puppet Labs\Puppet\puppet\bin\ruby" -e "puts Time.now.localtime.strftime('%Z').encoding"

I suspect that ruby is returning a UTF-16LE string?

Dominique Arpin (Jira)

unread,
Aug 31, 2021, 5:49:03 PM8/31/21
to puppe...@googlegroups.com

C:\windows\system32>"C:\Program Files\Puppet Labs\Puppet\puppet\bin\ruby" -e "pu
ts Time.now.localtime.strftime('%Z').encoding" {noformat}
CP850

I will try run this command on more computer, to see if I got the same value.

Ciprian Badescu (Jira)

unread,
Sep 13, 2021, 10:28:03 AM9/13/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: NW - 2021-10-06

Ciprian Badescu (Jira)

unread,
Sep 13, 2021, 10:29:02 AM9/13/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Team: Night's Watch

Ciprian Badescu (Jira)

unread,
Sep 22, 2021, 4:16:02 AM9/22/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Story Points: 2

Luchian Nemes (Jira)

unread,
Sep 22, 2021, 5:08:03 AM9/22/21
to puppe...@googlegroups.com
Luchian Nemes assigned an issue to Luchian Nemes
Change By: Luchian Nemes
Assignee: Luchian Nemes

Luchian Nemes (Jira)

unread,
Sep 22, 2021, 7:19:03 AM9/22/21
to puppe...@googlegroups.com
Luchian Nemes updated an issue
Change By: Luchian Nemes
Attachment: image-2021-09-22-14-18-43-384.png

Luchian Nemes (Jira)

unread,
Sep 22, 2021, 7:22:02 AM9/22/21
to puppe...@googlegroups.com
Luchian Nemes updated an issue
Change By: Luchian Nemes
Attachment: image-2021-09-22-14-21-56-439.png

Luchian Nemes (Jira)

unread,
Sep 22, 2021, 7:26:02 AM9/22/21
to puppe...@googlegroups.com

Dominique Arpin, we were unable to reproduce this. From my understanding, you’re seeing the expected behaviour with Puppet 6.24.0 and the issue with Puppet 7+ (please correct me if I’m wrong) but from my investigation I got the exact opposite results.

With the following versions installed:

C:\> puppet --version
6.24.0
 
C:\> facter --version
3.14.19 (commit f3c68a6f636c5e5eb94fd4add78ee5fc8ed33182)
 
C:\> facter-ng --version
4.2.2

Got this output:

(Pasted output as image to not let JIRA create an extra layer of confusion)

 

And with the following versions installed:

C:\> puppet --version
 7.11.0
C:\> facter --version
 4.2.4

Got this output:

(Pasted output as image to not let JIRA create an extra layer of confusion) 

 

Please let us know if you're still seeing this issue, if changing the code page to 1252 helps or if you have any information that could help us further this investigation.

Luchian Nemes (Jira)

unread,
Oct 1, 2021, 9:50:02 AM10/1/21
to puppe...@googlegroups.com
Luchian Nemes updated an issue
Change By: Luchian Nemes
Attachment: image-2021-10-01-16-49-51-786.png

Ciprian Badescu (Jira)

unread,
Oct 4, 2021, 4:25:01 PM10/4/21
to puppe...@googlegroups.com

Dominique Arpin (Jira)

unread,
Oct 5, 2021, 10:14:02 AM10/5/21
to puppe...@googlegroups.com

I can make some test if you want to check if the value is known by ruby.

Ciprian Badescu (Jira)

unread,
Oct 6, 2021, 5:01:04 AM10/6/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: NW - 2021-10-06 , NW - 2021-10-20

Gabriel Nagy (Jira)

unread,
Oct 6, 2021, 6:06:03 AM10/6/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Oct 6, 2021, 6:07:03 AM10/6/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Component/s: Facter 3
Component/s: Facter 4

Ciprian Badescu (Jira)

unread,
Oct 6, 2021, 6:07:04 AM10/6/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Fix Version/s: FACT 4.2.6

Josh Cooper (Jira)

unread,
Oct 8, 2021, 3:23:04 PM10/8/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-3068

This broke Facter acceptance on Japanese Windows, and I left a comment in https://github.com/puppetlabs/facter/pull/2446#issuecomment-939040529.

We used to retrieve the time zone as:

 Time.now.localtime.strftime('%Z')

And now we're calling:

timezone = Time.now.zone
 @fact_list[:timezone] = timezone.force_encoding("CP#{codepage}")

When running this script on Japanese Windows:

zone1 = Time.now.zone
puts zone1
puts zone1.encoding.name
puts zone1.valid_encoding?
zone1.force_encoding("CP932")
puts zone1.encoding.name
puts zone1.valid_encoding?
 
puts zone2 = Time.now.localtime.strftime('%Z')
puts zone2.encoding
puts zone2.valid_encoding?
 
puts zone1.encoding == zone2.encoding
puts zone1 == zone2

I get:

C:\ProgramData\PuppetLabs>ruby zone.rb
協定世界時
Windows-31J
true
Windows-31J
true
協定世界時
UTF-8
true
false
false

So it seems like somehow we used to rely on the timezone encoding being incorrect. It may be that we can call Time.now.zone, but we should transcode the value to UTF8. Something like:

zone = Time.now.zone
zone.force_encoding("CP932")
zone.encode!('UTF-8')

Ciprian Badescu (Jira)

unread,
Oct 20, 2021, 4:20:03 AM10/20/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: NW - 2021-10-06, NW - 2021-10-20 , NW - 2021-11-03

Luchian Nemes (Jira)

unread,
Nov 1, 2021, 9:18:02 AM11/1/21
to puppe...@googlegroups.com
Luchian Nemes updated an issue
Change By: Luchian Nemes
Release Notes: Bug Fix
Release Notes Summary: This release adds a new `timezone` resolver specific to Windows which checks the system codepage and uses it for encoding the timezone fact to avoid unwanted characters on non-English OS.
Reply all
Reply to author
Forward
0 new messages