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

Unexpected behavior around folded block scalars #827

Open
dangermike opened this issue Mar 2, 2022 · 0 comments
Open

Unexpected behavior around folded block scalars #827

dangermike opened this issue Mar 2, 2022 · 0 comments

Comments

@dangermike
Copy link

I'm seeing doubling of the first newline when using the folding style of block. I can replicate this using yaml.Node{...}, but it seems clearer to parse a string directly. This is my test harness:

package main

import (
	"os"

	yaml "gopkg.in/yaml.v3"
)

func main() {
	src := []byte(`
>
  line 1
  line 2
  line 3
    line 4
`)

	var data yaml.Node
	if err := yaml.Unmarshal(src, &data); err != nil {
		panic(err)
	}

	enc := yaml.NewEncoder(os.Stdout)
	if err := enc.Encode(&data); err != nil {
		panic(err)
	}
	enc.Close()
}```

The result is:

```text
>
    line 1 line 2 line 3

      line 4
      

The second newline between 3 & 4 is, I think a mistake. It becomes clearer if we indent line 2 like so (test):

	src := []byte(`
>
  line 1
    line 2
    line 3
      line 4
`)

This results in:

>
    line 1

      line 2
      line 3
        line 4

This is definitely incorrect.

michaeljmarshall pushed a commit to datastax/pulsar-helm-chart that referenced this issue Mar 15, 2022
Zookeeper has a yaml `zookeeper-metadata.yaml` that contains multiline string fields.
You will see something like this in that file
```yaml
args:
  - >
    bin/pulsar initialize-cluster-metadata \
```

The problem with this is that the main library in Go for parsing yaml contains a [bug](go-yaml/yaml#827) and it is not able to generate the yaml files correctly.


I'm using [Kustomize](https://kustomize.io/) to deploy my helm charts (which uses that yaml library) and that is breaking the deployment.

Yaml also has another syntax for multiline string that works just fine

```yaml
args:
  - |
    bin/pulsar initialize-cluster-metadata \
```

kafkaesque-io/pulsar-helm-chart#92
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

1 participant