Bug #8667

Randomly appearing "\" character in long string parameters

Added by Anthony Lapenna over 4 years ago. Updated over 4 years ago.

External Nodes
Target version:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:


This issue is happening with long string puppet class parameter.

Here is the string I'm trying to set in a parameter:

  <logger name="com.workit" additivity="false">
    <level value="DEBUG" />
    <appender-ref ref="APPLICATION_LOG_FILE" />

I'm using space indentation there (note that it's important).

Here is the result in the host yaml:

    configuration: ! "<logger name=\"com.workit\" additivity=\"false\">\r\n    <level
      value=\"DEBUG\" />\r\n    <appender-ref ref=\"APPLICATION_LOG_FILE\" />\r\n
      \ </logger>" 

See the "\" before the </logger>? Breaking the configuration.

Now, if I try with tab-indentation the same parameter, here is the host yaml output:

    configuration: ! "<logger name=\"com.workit\" additivity=\"false\">\r\n\t\t<level
      value=\"DEBUG\" />\r\n\t\t<appender-ref ref=\"APPLICATION_LOG_FILE\" />\r\n\t</logger>" 

I've setup the priority to HIGH as it's a breaking service configuration issue.


#1 Updated by Greg Sutcliffe over 4 years ago

  • Category set to External Nodes
  • Target version set to 1.7.2

I've been debugging this for a while, and I'm fairly stuck.

The extra "\" is saved to the db:

sqlite> select value from lookup_values;
--- ! "<configuration debug=\"false\" scan=\"true\">\r\n  <appender name=\"STDOUT\" 
  class=\"ch.qos.logback.core.ConsoleAppender\">\r\n    <encoder>\r\n      <pattern>foo</pattern>\r\n
  \   </encoder>\r\n  </appender>\r\n</configuration>"

It's definitely not present in the data sent from the form:

Parameters: ... "0"=>{"match"=>"", "use_puppet_default"=>"0", "value"=>"<configuration debug=\"false\" scan=\"true\">\r\n  <appender name=\"STDOUT\" class=\"ch.qos.logback.core.ConsoleAppender\">\r\n    <encoder>\r\n      <pattern>foo</pattern>\r\n    </encoder>\r\n  </appender>\r\n</configuration>", "_destroy"=>"false", "id"=>"1"}}, "id"=>"1"}}, ...

So, that implies it's somewhere in the save of the value.

I added `before_save :test` and `def test; binding.pry ; end` to the lookup_values model, so I could check the value, and it was still without extra slashes.

At this point, my suspicion is that the "serialize :value" call in app/models/lookup_value.rb is somehow mangling the data, but I'm struggling to prove it. I'm testing on sqlite, for the record.

#2 Updated by Greg Sutcliffe over 4 years ago

  • Status changed from New to Rejected

After extensive digging, it seems this is not a bug, but rather a ruby version mismatch. It seems that the YAML parser in ruby 1.9.3 adds '\' as an automated form of line break, and can handle parsing it back out, but ruby 1.8 doesn't, and can't handle parsing them back out

This leads to the above behaviour if your foreman server has been upgraded to 1.9 but your pupper server hasn't been upgraded from 1.8.7 yet. Foreman's 1.9.3 will add the \ but Puppet's 1.8.7 won't parse it out, and thus you get \ in your templates.

Thanks to Anthony for his patience on irc - closing this as not-a-bug :)

Also available in: Atom PDF