-
Notifications
You must be signed in to change notification settings - Fork 141
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
Inconsistent conversion of strings from json to yaml #41
Comments
Ok, this is a very interesting bug. Yaml actually treats any unquoted string of digits that begins with a zero as an octal number so this will produce strange results. I will look into this shortly. |
That makes a lot more sense. I look forward to your solution. BTW, I fixed my multi-string line comments in my previous comment. Sorry for any frustration that may have caused you. |
+1 for me. trying to create CF with Peer connection with an account ID with leading zero. and failed. also can't use ARN in this case as the parameter require account ID |
Trying to find out how to fix this. and found this funny issue
it is only break if the string is long enough... |
related to yaml/pyyaml#98 |
Ok, so I've been digging in to this and pyyaml's behaviour is actually perfectly fine. It only omits quotes when the number could not parse as a valid octal number - for example, if it contains a digit higher than '7'.
Which pyyaml then correctly loads back in as strings in both cases:
So given that the output from pyyaml is correct, valid yaml with no ambiguity (a sequence of digits that begins with '0' but contains invalid octal digits, e.g. '8' or '9' is correctly interpreted as a string)... where is the issue seen? |
@stilvoid take a look at this issue cloudtools/troposphere#994 where an AWS account ID run through cfn-flip to yaml will have the leading 0 truncated causing an illegal account ID in CloudFormation. |
Ok, so it looks like a difference in implementation of the yaml spec. pyyaml (used by cfn-flip) treats invalid sequences of digits (e.g. |
Ok, I think I've fixed this in the branch issue-41 I'll try it out with a few templates to make sure. |
@stilvoid The plain scalar |
Actually, see the discussion in yaml/pyyaml#98 |
I am converting a document from json to yaml as part of a CloudFormation Template, and am noticing an odd error where some Id's that are marked as strings are being converted to strings, and other times not.
Here's a json snippet I'm working with right now which are the mappings for some of the Generic Elastic Load Balancer ID's for AWS:
And This is the resulting yaml I'm getting after calling to_yaml:
Strangely enough, any number beginning with 0 is converted, but the ones beginning with other numbers do not. I'm not sure what the expected behavior should be in this case, (either fully converted or not) but having it half and half is inconsistent, and I would believe is a bug.
Currently I'm having errors with using this yaml with sceptre/CloudFormation due to some of the Elastic Load Balancer ID's not being strings.
The text was updated successfully, but these errors were encountered: