lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.07k stars 591 forks source link

limayaml.Save does have some encoding bugs #2665

Open jandubois opened 16 hours ago

jandubois commented 16 hours ago
  1. The function uses a custom marshaller to make sure null and ~ are quoted. It is missing entries for Null and NULL which in the YAML spec also denote the missing value.

  2. I found that tab characters get an extra backslash during the roundtrip (I've filed https://github.com/goccy/go-yaml/issues/475) for this. This bug only happens when using a custom marshaller, but not with the default one.

So (1) can be fixed by added the missing cases, but (2) can only be fixed by removing the custom marshaller, making it impossible to fix (1).

But by lucky synchronicity a PR has been filed just 10 hours ago to fix the null issue upstream (https://github.com/goccy/go-yaml/pull/474). I've tested that branch, and it fixes both (1) and (2) when you remove the custom marshaller.

So it is possible to fix the issue right away with a replace directive in go.mod and dropping the custom marshaller:

replace github.com/goccy/go-yaml => github.com/denieryd/go-yaml v0.0.0-20240927195919-fa39d09da8ae

I don't think this is important enough, and we should instead wait a while to see if upstream makes a release. We could fix (1) while we wait, if we want to.