fix: audit YAML validation and add TestCase unknown field test (#132)#206
Merged
Conversation
Audit findings: - All primary user config loaders (LoadBenchmarkSpec, LoadTestCase, ParseSpec, ProjectConfig.Load, suggest.validateEvalYAML, jsonrpc eval validate) already use decoder.KnownFields(true) — strict. - Two yaml.Unmarshal calls in cmd_coverage.go and cmd_check.go are intentional partial parses (only read subset of fields); making them strict would break valid eval.yaml files. - internal/generate, internal/skill, internal/validation use non-strict parsing by design (frontmatter extensibility, schema probing, generic any decode). Changes: - Add TestLoadTestCase_UnknownFieldRejected proving bogus fields are rejected by LoadTestCase's KnownFields(true) decoder. - Remove broken TestLoadTestCase_FollowUpPrompts that referenced non-existent TestStimulus.FollowUps field (prevented package compilation on main). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Summary
Closes #132
Audit Results
Audited all
yaml.Unmarshalandyaml.NewDecodercalls across the Go codebase. Finding: all user-facing config loaders already use strict parsing.Already strict (
KnownFields(true)):LoadBenchmarkSpecinternal/models/spec.go:226GraderConfig.UnmarshalYAMLinternal/models/spec.go:79LoadTestCaseinternal/models/testcase.go:227ValidatorInline.UnmarshalYAMLinternal/models/testcase.go:103DecodeGraderParamsinternal/models/grader_params.go:252trigger.ParseSpecinternal/trigger/spec.go:27ProjectConfig.Loadinternal/projectconfig/config.go:203jsonrpc eval validateinternal/jsonrpc/handlers.go:223suggest.validateEvalYAMLinternal/suggest/suggest.go:336suggest.parseSuggestioninternal/suggest/suggest.go:202Intentionally non-strict (correct):
cmd_coverage.go/cmd_check.go— partial struct parses that only read subset of eval.yaml fieldsinternal/generate— skill frontmatter (documented: allows extra fields for other tools)internal/skill— frontmatter generic/node parseinternal/validation/schema.go— schema probing intoanyinternal/suggest— grader type probingChanges
TestLoadTestCase_UnknownFieldRejected— proves that a task YAML withbogus_field: trueis rejectedTestLoadTestCase_FollowUpPrompts— referenced non-existentTestStimulus.FollowUpsfield, prevented package compilation on mainTesting