Default to yaml when a file's extension is not a recognised format (#2785)

* Default to yaml for unrecognised file extensions in format auto-detection

* Add test for unrecognised extension defaulting to yaml
This commit is contained in:
Dev Kumar
2026-08-03 11:37:38 +10:00
committed by GitHub
parent b7a06d6e1f
commit 341734d6ec
2 changed files with 8 additions and 2 deletions
+3
View File
@@ -59,4 +59,7 @@ func TestFormatStringFromFilename(t *testing.T) {
test.AssertResult(t, "json", FormatStringFromFilename("TEST.JSON"))
test.AssertResult(t, "yaml", FormatStringFromFilename("test.json/foo"))
test.AssertResult(t, "yaml", FormatStringFromFilename(""))
// unrecognised extensions should default to yaml instead of being passed through verbatim
// (see https://github.com/mikefarah/yq/issues/1608)
test.AssertResult(t, "yaml", FormatStringFromFilename("test.tfstate"))
}