fix: recover config from unparseable ENV file entries

An ENV file holding an entry the parser rejects made every config read for that app fail outright, so the existing recovery that drops invalid keys and rewrites the file never had a chance to run. This went unnoticed because two environment test fixtures had gone stale against parser leniency that no longer exists, and the module manifest was out of date enough that its tests refused to run at all.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-09-22 15:59:25 -04:00
1 parent 86e96f0946
commit 47de42cd79
2 files changed
+34 -7

No files matched your search

+4 -2
View File
@@ -46,14 +46,16 @@ func TestMerge(t *testing.T) {
e.Merge(e2)
Expect(e.Map()).To(Equal(pairs("BAR", "baz", "FOO", "bar")))
e3, _ := newEnvFromString("FOO='ba \\nz'")
e3, err := newEnvFromString("FOO=\"ba \\nz\"")
Expect(err).NotTo(HaveOccurred())
e.Merge(e3)
Expect(e.Map()).To(Equal(pairs("BAR", "baz", "FOO", "ba \nz")))
}
func TestExport(t *testing.T) {
RegisterTestingT(t)
e, _ := newEnvFromString("BAR='BAZ'\nFOO='b'ar '\nBAZ='a\\nb'")
e, err := newEnvFromString("BAR='BAZ'\nFOO=\"b'ar \"\nBAZ=\"a\\nb\"")
Expect(err).NotTo(HaveOccurred())
Expect(e.Export(ExportFormatEnvfile)).To(Equal("BAR=\"BAZ\"\nBAZ=\"a\\nb\"\nFOO=\"b'ar \""))
Expect(e.Export(ExportFormatDockerArgs)).To(Equal("--env=BAR='BAZ' --env=BAZ='a\nb' --env=FOO='b'\\''ar '"))
Expect(e.Export(ExportFormatDockerArgsKeys)).To(Equal("--env=BAR --env=BAZ --env=FOO"))