Skip to content

yq drops newline between flow-style entry and multiline map key #2546

@d-enk

Description

@d-enk

Description

When yq processes a YAML file that contains a flow-style mapping entry followed by a multiline map key, the newline between them is not preserved.

As a result, the multiline key is concatenated onto the previous line, producing invalid YAML output.


Reproduction

Input file (test.yaml):

arr: [1, 2, 3]

? |
  multi
  line
  key
: value

Note that:

  • arr is written in flow style
  • the next mapping entry uses a multiline block scalar as a key
  • there is a blank line separating them

Command

yq test.yaml

Actual Output

arr: [1, 2, 3]? |
  multi
  line
  key
: value

The newline between the flow-style entry (arr: [1, 2, 3]) and the multiline key is lost, causing the multiline key (? |) to be appended to the previous line.


Expected Output

The newline should be preserved:

arr: [1, 2, 3]
? |
  multi
  line
  key
: value

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions