Skip to content

Commit 6e43792

Browse files
Validate file extension before creating empty file
Move validateConfigFileExtension call before file.CreateEmptyIfNotExists to avoid creating unnecessary files with invalid extensions on the filesystem. This addresses the review comment by ensuring validation happens first. Co-authored-by: dlevy-msft-sql <[email protected]>
1 parent eeb651b commit 6e43792

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ func SetFileName(name string) {
2626

2727
filename = name
2828

29+
// Validate file extension before creating the file
30+
err := validateConfigFileExtension(filename)
31+
checkErr(err)
32+
2933
file.CreateEmptyIfNotExists(filename)
30-
err := configureViper(filename)
34+
err = configureViper(filename)
3135
checkErr(err)
3236
}
3337

0 commit comments

Comments
 (0)