google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
7.01k stars 440 forks source link

std.parseYaml wraps result in an array when string values contain --- #1147

Closed SamuraiPrinciple closed 7 months ago

SamuraiPrinciple commented 8 months ago

Example:

[
  std.parseYaml('a: good--'),
  std.parseYaml('a: bad---'),
]

Produces:

[
   {
      "a": "good--"
   },
   [
      {
         "a": "bad---"
      }
   ]
]
johnbartholomew commented 7 months ago

Hi. Thanks for the bug report. Could you confirm exactly which version of jsonnet you see this behaviour with? If you've built it yourself, specifying which git commit (also how you build it would be good, since it can be configured with a bundled YAML parsing library or configured to use one from your system). If you're using a binary from somewhere else, running jsonnet --version should give some version information.

So far I have not been able to reproduce this myself, so I am probably running a different version of jsonnet.

SamuraiPrinciple commented 7 months ago

Hi. Many thanks for the quick reply.

Initially, I've observed the issue on argocd which seems to be using go-jsonnet.

If I hijack one of the examples on jsonnet.org website, I'm able to reproduce it as well:

Screenshot 2024-04-01 at 15 18 05

I'm also able to reproduce it with vscode jsonnet language server plugin (that seems to be using go-jsonnet too) https://marketplace.visualstudio.com/items?itemName=Grafana.vscode-jsonnet:

Screenshot 2024-04-01 at 15 24 07

I have just realised that my local jsonnet version was actually go-jsonnet (and it's also affected) which leads me to the conclusion that I've got it wrong way around - it's most likely that only the go version is affected.

Apologies for the confusion, feel free to close the issue.

johnbartholomew commented 7 months ago

Thanks. I see you've opened https://github.com/google/go-jsonnet/issues/749 so I'll close this one.