fix: surface dropped error in file_existence check#2
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
FileExistenceTest.Validate()(pkg/types/v1/file_existence.go) constructed anfmt.Errorffor the empty-Pathcase but never returned it — the function fell through toreturn nil.go vetflags this asresult of fmt.Errorf call not used. The siblingFileContentTest.Validate()returns the equivalent error, confirming the droppedreturnis a typo.Impact
StructureTest.RunFileExistenceTests(pkg/types/v1/structure.go:87) callsValidate()and skips the test on error. Because the empty-Patherror was swallowed, a file-existence test missing the requiredpathfield passed validation and was executed — callingdriver.StatFile("")— instead of being rejected with the clearPlease 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
returnso the empty-Patherror surfaces (matchingFileContentTest.Validate).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.