fix(validate): catch config mistakes a run reports silently#40
Open
rickliujh wants to merge 1 commit into
Open
fix(validate): catch config mistakes a run reports silently#40rickliujh wants to merge 1 commit into
rickliujh wants to merge 1 commit into
Conversation
loom validate accepted several configs that a real run then got wrong without saying so: - Exclude/include patterns are matched against base names with filepath.Match, whose error is discarded — a malformed pattern or one carrying a path separator silently matched nothing, so files meant to be filtered were rendered into the target. - A patch file that survives a newFiles walk is delivered as module output instead of being applied as a patch (the __functions footgun). - patch.target / newFiles.dest / llm.target were joined to the target dir unchecked, so a "../" prefix wrote outside it. - llm.maxTokens < 0 was dropped at call time (only > 0 is forwarded). All four are now violations, reported with the rest in one pass and skipped when the value is templated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
loom validateaccepted several configs that a real run then got wrong without saying so. Each gap below is a case where nothing — not validate, not the run — tells you the module misbehaved.Same fixture module, before vs. after:
What was missing
filepath.Matchand discards its error (internal/util/fs.go:27). So"__functions["(malformed) and"__functions/patches/*.yaml"(separator) each matched nothing, silently, and the files they were meant to filter were rendered into the target. Empty patterns too.newFilesoutput — the F3__functionsfootgun.ValidateInDirnow replays the real walk filter over each non-templatednewFiles.sourceand errors if a patch file survives it. Skipped when any exclude/include is templated, since the run-time filter would differ.patch.target,newFiles.destandllm.targetwerefilepath.Join'd to the target dir unchecked, so a../prefix wrote outside the clone.llm.maxTokens < 0was dropped at call time (pkg/llm/llm.go:52only forwards> 0), so a negative limit was silently ignored.retriesalready had this check.All four are reported with the rest of the violations in one pass, and all are skipped when the field is templated.
Also
specs/module.md: new rows in the Validation Rules table plus a note on why these two classes are rejected (the run cannot report them).docs/reference/cli-validate.md: the "What It Checks" list was badly stale — it omitted template checks, filesystem checks, required fields and most enums, and claimed success prints nothing.Test plan
pkg/config/validate_test.gocovering each rule, its templated-skip path, and the valid cases.go build ./...andgo test ./...green.loom run --local-run, and that the new binary rejects the config.Not included
A param name that isn't a valid Go template identifier (
my-param) is unusable via{{ .my-param }}but legal via{{ index . "my-param" }}, so flagging it would risk false positives. Left alone.🤖 Generated with Claude Code