Error: Could not retrieve catalog from remote server: Could not intern from application/json: Internal Error: Puppet Context ':loaders' missing
|
3. Puppet only displays diffs when it updates an existing file. It doesn't display a diff when creating a new file. So to reliably trigger this issue you have to create a mismatched file. 4. The show_diff setting is automatically enabled when running puppet agent -t, but not puppet apply. This issue is reproducible when using puppet apply --show_diff. So it's not specific to apply or agent:
rm /tmp/test && touch /tmp/test && bundle exec puppet apply --show_diff manifest.pp |
Notice: Compiled catalog for localhost in environment production in 0.02 seconds |
Notice: /Stage[main]/Main/File[/tmp/test]/content: Received a Log attribute with invalid encoding:"\n--- /tmp/test\t2019-10-31 14:21:21.000000000 -0700\n+++ /var/folders/8m/d6146zxd6bv_3h8y4ykvvxh40000gn/T/puppet-file20191031-99254-1g938g5\t2019-10-31 14:21:26.000000000 -0700\n@@ -0,0 +1 @@\n+\xC7\xD1\xFC\x84\n\\ No newline at end of file\n"\nBacktrace: |
/Users/josh/work/puppet/lib/puppet/util/log.rb:190:in `newmessage' |
/Users/josh/work/puppet/lib/puppet/util/log.rb:315:in `initialize' |
/Users/josh/work/puppet/lib/puppet/util/log.rb:88:in `new' |
/Users/josh/work/puppet/lib/puppet/util/log.rb:88:in `create' |
/Users/josh/work/puppet/lib/puppet/util/logging.rb:11:in `send_log' |
/Users/josh/work/puppet/lib/puppet/util/logging.rb:20:in `block (2 levels) in <module:Logging>' |
/Users/josh/work/puppet/lib/puppet/type/file/data_sync.rb:45:in `block in checksum_insync?' |
/Users/josh/work/puppet/lib/puppet/type/file/data_sync.rb:19:in `write_temporarily' |
/Users/josh/work/puppet/lib/puppet/type/file/data_sync.rb:44:in `checksum_insync?' |
/Users/josh/work/puppet/lib/puppet/type/file/content.rb:106:in `insync?' |
Notice: /Stage[main]/Main/File[/tmp/test]/content: content changed '{md5}d41d8cd98f00b204e9800998ecf8427e' to '{md5}387d16f3cb61048e6fb16cfd81367ce8'
|
5. The error occurs because the diff command returns a UTF-8 string, but the encoding is not valid (the underlying bytes are not a valid UTF-8 sequence):
(byebug) diff(resource[:path], path).encoding |
#<Encoding:UTF-8> |
(byebug) diff(resource[:path], path).valid_encoding? |
false |
(byebug)
|
The same occurs when executing the diff command directly from ruby:
irb(main):003:0> %x(diff #{oldpath} #{newpath}) |
=> "0a1\n> \xC7\xD1\xFC\x84\n\\ No newline at end of file\n" |
irb(main):004:0> %x(diff #{oldpath} #{newpath}).encoding |
=> #<Encoding:UTF-8> |
irb(main):005:0> %x(diff #{oldpath} #{newpath}).valid_encoding? |
=> false
|
6. The error message occurs because our logging code protects against log messages with invalid encodings, see PUP-1441. So we log that the message we were asked to log is invalid along with the stack trace. For this ticket, I think we should validate the string returned by the diff command. If the encoding is not valid or if the encoding is binary, then we should log a message that the diff cannot be displayed. |