fix(checkers): load custom YAML checkers from disk, not embedded FS#230
Merged
sanket-deepsource merged 1 commit intomasterfrom Apr 19, 2026
Merged
fix(checkers): load custom YAML checkers from disk, not embedded FS#230sanket-deepsource merged 1 commit intomasterfrom
sanket-deepsource merged 1 commit intomasterfrom
Conversation
`LoadCustomYamlCheckers(dir)` walks `os.DirFS(dir)` to find YAML files on local disk, but the closure it used read file content via `builtinCheckers.ReadFile(path)` — i.e. always the embedded FS. For every custom YAML file, `ReadFile` returned `fs.ErrNotExist`, the error was silently swallowed by the top-level error check in the walk callback, and the checker was never loaded. Net result: `globstar check --checkers=local` in a repo with a `.globstar/*.yml` found zero issues regardless of the YAML's content, while the same YAML loaded via `--checkers=builtin` worked fine — confirming the loader (not the YAML) was the problem. Fix: thread a per-backend `readFile func(string) ([]byte, error)` through `findYamlCheckers`. `LoadBuiltinYamlCheckers` passes `builtinCheckers.ReadFile`; `LoadCustomYamlCheckers` passes a closure that reads from disk via `os.ReadFile(filepath.Join(dir, p))`. No public API breakage. Add a regression test that writes a YAML checker to a temp dir and asserts `LoadCustomYamlCheckers` returns it.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
Problem
LoadCustomYamlCheckers(dir)incheckers/checker.gowalksos.DirFS(dir)withfs.WalkDirto discover YAML files on the localdisk, but the closure it shared with the builtin loader
(
findYamlCheckers) read file content viabuiltinCheckers.ReadFile(path)— i.e. always the embedded FS, neverthe local filesystem.
For every custom YAML file,
ReadFilereturnedfs.ErrNotExist, theerror was silently swallowed by the top-level error check in the walk
callback (
if err != nil { return nil }), and the checker was neverloaded. Net result:
globstar check --checkers=localin a repo with a.globstar/*.ymlfound zero issues regardless of the YAML's content.Reproduction (against v0.7.0)
Fix
Thread a per-backend
readFile func(string) ([]byte, error)throughfindYamlCheckers:LoadBuiltinYamlCheckerspassesbuiltinCheckers.ReadFileLoadCustomYamlCheckerspasses a closure that reads from disk viaos.ReadFile(filepath.Join(dir, p))No public API changes — only the unexported helper signature changes.
Tests
checkers/checker_test.gowithTestLoadCustomYamlCheckers_ReadsFromDisk,which writes a YAML checker to a
t.TempDir()and asserts thechecker is returned in the language map. Verified the test fails on
the pre-fix code and passes after.
go test ./checkers/... ./analysis/... ./pkg/...all pass.make generate-registry && go build ./cmd/globstarbuilds cleanly.