Skip to content

fix: surface dropped error in file_existence check#2

Merged
thomasdesr merged 1 commit into
mainfrom
thomas/fix-file-existence-vet
Jun 29, 2026
Merged

fix: surface dropped error in file_existence check#2
thomasdesr merged 1 commit into
mainfrom
thomas/fix-file-existence-vet

Conversation

@thomasdesr

Copy link
Copy Markdown

Bug

FileExistenceTest.Validate() (pkg/types/v1/file_existence.go) constructed an fmt.Errorf for the empty-Path case but never returned it — the function fell through to return nil. go vet flags this as result of fmt.Errorf call not used. The sibling FileContentTest.Validate() returns the equivalent error, confirming the dropped return is a typo.

Impact

StructureTest.RunFileExistenceTests (pkg/types/v1/structure.go:87) calls Validate() and skips the test on error. Because the empty-Path error was swallowed, a file-existence test missing the required path field passed validation and was executed — calling driver.StatFile("") — instead of being rejected with the clear Please provide a valid file path for test <name> message. A malformed test definition silently produced a confusing runtime result rather than an upfront validation failure.

Fix

  • Add the missing return so the empty-Path error surfaces (matching FileContentTest.Validate).
  • Add a table-driven check (file_existence_test.go) covering missing-name, missing-path, and valid cases. Verified RED before the fix (only the missing-path case failed) and GREEN after.

Verification

go build ./..., go vet ./pkg/types/v1/ (finding gone), and the package + full suite all pass.

FileExistenceTest.Validate() constructed an fmt.Errorf for the empty-Path
case but never returned it, so the function fell through to return nil. A
test definition missing the required `path` field passed validation and was
executed (driver.StatFile("")) instead of being skipped with a clear error,
unlike the matching FileContentTest.Validate which returns the error.

Add the missing return and a table test covering missing-name, missing-path,
and valid cases. Clears the 'result of fmt.Errorf call not used' go vet finding.
@thomasdesr thomasdesr merged commit e4614ff into main Jun 29, 2026
8 of 10 checks passed
@thomasdesr thomasdesr deleted the thomas/fix-file-existence-vet branch June 29, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant