question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dump fails to quote strings with leading zeros if any chars are non-octal

See original GitHub issue
jsyaml = require('js-yaml');
console.log(jsyaml.dump("007"));
console.log(jsyaml.dump("008"));

Should output

'007'

'008'

but it outputs

'007'

008

I’m running into this with AWS account ids that start with two leading 0s and this is causing issues with CloudFormation templates as CloudFormation then mangles the numbers further.

This case should be handled in the testAmbiguousType function passed to chooseScalarStyle in dumper.js.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tavisruddcommented, Feb 1, 2018

You’re missing the point, I’m not suggesting 008 is a valid octal number. Rather, CloudFormation and probably other tools are parsing it as number when not quoted. If js-yaml were to quote such strings, this bad interaction could be avoided.

1reaction
puzrincommented, Feb 1, 2018

If you need quick and dirty workaround - use JSON.stringify(), it’s compatible with yaml.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to dump a digit string with leading zeros, as a valid yaml ...
Creating a yaml string with leading zeros is not escaped with quotes in yaml-cpp. So writing the string to a texfile is not...
Read more >
perldiag - ActivePerl 5.26 Documentation
(P) An error peculiar to VMS. Perl thought stdin was a pipe, and tried to reopen it to accept binary data. Alas, it...
Read more >
HON EYVVE LL . - Bitsavers.org
If no match strings are supplied, no string matching is ... dumped to see the events leading up to a particular error condition,...
Read more >
Проект OpenNet: MAN zshbuiltins (1) Команды и прикладные ...
If no command is specified, print the binding of in-string if it is bound, ... the zero; a non-octal digit ter- minates the...
Read more >
RfD: Escaped Strings - Google Groups
corresponds to the current ANS definition of a character. ... \q double-quote (ASCII 34) ... \[0-7]+ Octal numerical character value, finishes at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found