Skip to content
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

std.parseYaml() parses quoted numbers as numbers #1050

Closed
vincentmrg opened this issue Mar 6, 2023 · 5 comments
Closed

std.parseYaml() parses quoted numbers as numbers #1050

vincentmrg opened this issue Mar 6, 2023 · 5 comments
Assignees

Comments

@vincentmrg
Copy link

Hello,

It looks like the std.parseYaml function parses quoted numbers as numbers (instead of string).
e.g.

bash-5.1$ cat test.jsonnet 
local yaml = 'id: "91372278466"\nname: staging\n';
std.parseYaml(yaml)
bash-5.1$ jsonnet test.jsonnet 
{
   "id": 91372278466,
   "name": "staging"
}

Another unexpected behavior is that this function fails if said number starts with a 0.
e.g.

bash-5.1$ cat test.jsonnet 
local yaml = 'id: "091372278466"\nname: staging\n';
std.parseYaml(yaml)
bash-5.1$ jsonnet test.jsonnet 
Something went wrong during jsonnet_evaluate_snippet, please report this: [json.exception.parse_error.101] parse error at line 1, column 19: syntax error while parsing object - unexpected number literal; expected '}'
Abort trap: 6
@sparkprime
Copy link
Collaborator

I'm guessing this is an issue with the underlying parser? Was it C++ or Go

@vincentmrg
Copy link
Author

It was with the C++ version. I just tested with the go implementation, it works fine.

@sparkprime
Copy link
Collaborator

It's probably a bug in RapidYAML then

@johnbartholomew johnbartholomew self-assigned this Feb 9, 2024
@johnbartholomew
Copy link
Collaborator

This one should be fixed by #1134 (upgrading RapidYAML to 0.5.0)

@johnbartholomew
Copy link
Collaborator

Should work on master now. I have added a test case for it (#1136). Thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants