Issue #16245 has been updated by eric sorenson.

Status changed from Unreviewed to Investigating
Assignee set to eric sorenson

I have seen this too (though your :8080 example is pretty baffling). Everything 
in Puppet's a string, except for a few things that aren't, and those will be 
type-coerced inside of puppet itself -- so turning off the automatic typing in 
your YAML emitter is definitely a safer way to go.

I'll investigate whether there is something special about the `:8080` that 
makes the `:` get stripped off; that would be a legitimate bug.
----------------------------------------
Bug #16245: ENC output is sometimes internalized with variables as the wrong 
types (str becomes int, etc)
https://projects.puppetlabs.com/issues/16245#change-70837

Author: Andrew Kesterson
Status: Investigating
Priority: Normal
Assignee: eric sorenson
Category: 
Target version: 
Affected Puppet version: 2.7.10
Keywords: 
Branch: 


We have an ENC that provides output in YAML format, and works 99.9% of the 
time. We appear to have discovered a bug in the puppet YAML parser (or, rather, 
whatever library puppet may be using to parse its YAML from the ENC). Our ENC 
is written in python, all data is stored in JSON internally, and it uses the 
pyyaml library to dump its output.

In this case, here is what we EXPECT to happen (in pseudocode):

    In our ENC, define a string called "port":
        {"port": ":8080"}
    ENC provides output as YAML
        port: ':8080'
    puppet consumes ENC output
        puppet says "That looks like a string"
        puppet creates a global variable
            $port = ':8080'
    
Unfortunately, here's what's REALLY happening:

    in our ENC, define a string called port:
        {"port": ":8080"}
    ENC provides output as YAML, but pyyaml fails to quote the string (which, 
according to the spec, appears to be fine?):
        apiPort: :8080
    puppet consumes ENC output
        puppet has some behavior that causes the following to occur sometimes, 
but not all the time (more data on this when I can get it):
            puppet says "That value has a leading : on it; I need to parse that 
some more, get rid of the :"
            puppet says "That looks like an integer"
            puppet creates a global variable
                $port = 8080

The only way to fix this (from our ENC, at least) is to tell pyyaml's safe_dump 
function to use the default flow style, which (according to pyyaml) does not 
allow ":" to start any string, and will therefore quote any string that starts 
with ":" (yes there is a specific exemption for this exact use case - funny). 
And this does, indeed, fix the output; the string is quoted as it should be, 
and puppet consumes the output happily, as a string, and no more confusion 
occurs. HOWEVER, this is explicitly listed as a violation of the YAML 
specification, and is a blatant hack, so we would prefer not to rely on it.

While the behavior of pyyaml here is questionable (and there may indeed be a 
bug filed with them over this), the behavior of puppet's yaml parser does seem 
to defy the standard; it seems that it should be consuming ":8080" as a string, 
even if it is unquoted.

This is a rather pesky bug that is doing a very good job of destroying faith in 
our ENC, and the idea that "what you put in the ENC is what you get in your 
puppet module". Any plans to fix this in puppet 3? Is there a fix already that 
I just don't know about?


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to