You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When serializing a flow mapping, the separating comma is appended to a trailing comment instead of after a value.
This results in an invalid yaml document (despite no changes being made to the document) because of a missing comma between flow map items.
This behavior does not occur with a flow sequence, just a flow map.
To Reproduce
constyaml=require('yaml')constassert=require('node:assert')consttextBefore=`test: { items: { first: { value: true }, # comment second: { value: true } }, array: [ first, # comment second ]}`consttextAfter=`test: { items: { first: { value: true } # comment, second: { value: true } }, array: [ first, # comment second ] }`constdoc=yaml.parseDocument(textBefore)constdocText=doc.toString()// no errorassert.equal(docText.trim(),textAfter)constdocAfter=yaml.parseDocument(docText)// throws error since expected is an array of one error:/*YAMLParseError: Missing , between flow map items at line 6, column 9: first: { value: true } # comment, second: { value: true } ^*/assert.deepStrictEqual(docAfter.errors,[])
Expected behaviour
Comma should be in the correct position so that the document still parses after being stringified
Versions (please complete the following information):
Describe the bug
When serializing a flow mapping, the separating comma is appended to a trailing comment instead of after a value.
This results in an invalid yaml document (despite no changes being made to the document) because of a missing comma between flow map items.
This behavior does not occur with a flow sequence, just a flow map.
To Reproduce
Expected behaviour
Comma should be in the correct position so that the document still parses after being stringified
Versions (please complete the following information):
yaml
: 2.4.0Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: