-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid byte sequence in UTF-8 #49
Comments
I have naively tried this patch, but still get the error:
I also tried to add LANG or LC_ALL=C.UTF-8 to the |
These characters do not really make sense for that option. Locally (Fedora) + on a debian/buster64 Vagrantbox I get:
It would be important to get that reproducible to get ruby parsing things correctly. |
This seems to be caused by a kernel bug in certain Debian versions: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=974193 |
but why is ruby trying to decode that stuff in the first place? seems like this code would be more solid if it wasn't trying to make any guesses about the encoding of sysctl... that said, i see the bug in an earlier version of linux (5.8) so I've fixed the affected versions in the debian BTS. thanks for that! :) |
Ruby reads Strings and by default it assumes the content is UTF-8 and while trying to parse it it fails: https://tenderlovemaking.com/2020/01/13/guide-to-string-encoding-in-ruby.html How else should it know how to represent it internally, so that you can actually read from it? As this article shows it highly depends on the context. And I would say it is fairly safe to say that Now the error is quite generic and you probably don't get immediately a clue why things failed. So we could wrap it, make it more nicer to have more context where it failed. On the other side, running |
latin1, as an encoding, has the surprising property of never failing to decode, for example, even if it might mean garbage in some cases. i'm not sure the kernel actually says what the encoding of sysctl is anywhere, it would be interesting to figure that out. that said, maybe for the purpose of this module it would be overkill to make changes to this... i do agree an improved error message would have made my life much easier: i spent a few hours tracing that and it was fairly frustrating. :) |
Did you use |
I have not. I wasn't familiar with that option. It does show it:
I (rather naively i guess?) used
which kind of does if you squint a little. It's how I decided to file the bug here and look at the |
When switching to this module from my dumb sysctl one, I get this error when running my manifest:
To reproduce:
Add this to a
reproducer.pp
file:Download the 0.0.12 module to
test-modules/sysctl
, and run this:I get this error:
This can also be reproduced in the git head. I can't find any corrupt UTF-8 output in the module's source code, so that can't be it.
My guess is that the output of
sysctl -a
makes Puppet unhappy: it might trying to decode it as unicode at some point and failing. And indeed, here, thesysctl -a
output isn't UTF-8 clean:It specifically stumbles upon
sunrpc.transports
, whichless
shows as:And indeed, this is happy:
I would recommend not making any assertions on the encoding of values in the kernel's sysctl output.
The text was updated successfully, but these errors were encountered: