In both mfer/checker.go and internal/checker/checker.go, the checkFile method has this code:
iferrors.Is(err,errors.New("file does not exist")){
errors.Is compares by identity (pointer equality), not by string value. errors.New() creates a new unique error value each time it is called, so this comparison will never be true. This is dead code that silently fails to detect missing files when the error message is "file does not exist" but is not afero.ErrFileNotFound.
The fallback afero.Exists() call partially masks this bug, but it causes an unnecessary extra filesystem stat call and could behave differently under race conditions.
Fix: Use os.ErrNotExist with errors.Is, which is the standard Go sentinel error for file-not-found across all platforms.
In both `mfer/checker.go` and `internal/checker/checker.go`, the `checkFile` method has this code:
```go
if errors.Is(err, errors.New("file does not exist")) {
```
`errors.Is` compares by identity (pointer equality), not by string value. `errors.New()` creates a new unique error value each time it is called, so this comparison **will never be true**. This is dead code that silently fails to detect missing files when the error message is "file does not exist" but is not `afero.ErrFileNotFound`.
The fallback `afero.Exists()` call partially masks this bug, but it causes an unnecessary extra filesystem stat call and could behave differently under race conditions.
**Fix:** Use `os.ErrNotExist` with `errors.Is`, which is the standard Go sentinel error for file-not-found across all platforms.
clawbot
self-assigned this 2026-02-08 21:01:31 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In both
mfer/checker.goandinternal/checker/checker.go, thecheckFilemethod has this code:errors.Iscompares by identity (pointer equality), not by string value.errors.New()creates a new unique error value each time it is called, so this comparison will never be true. This is dead code that silently fails to detect missing files when the error message is "file does not exist" but is notafero.ErrFileNotFound.The fallback
afero.Exists()call partially masks this bug, but it causes an unnecessary extra filesystem stat call and could behave differently under race conditions.Fix: Use
os.ErrNotExistwitherrors.Is, which is the standard Go sentinel error for file-not-found across all platforms.