Skip to content

fix: audit YAML validation and add TestCase unknown field test (#132)#206

Merged
spboyer merged 1 commit into
mainfrom
squad/132-yaml-validation
Apr 21, 2026
Merged

fix: audit YAML validation and add TestCase unknown field test (#132)#206
spboyer merged 1 commit into
mainfrom
squad/132-yaml-validation

Conversation

@spboyer

@spboyer spboyer commented Apr 21, 2026

Copy link
Copy Markdown
Member

Summary

Closes #132

Audit Results

Audited all yaml.Unmarshal and yaml.NewDecoder calls across the Go codebase. Finding: all user-facing config loaders already use strict parsing.

Already strict (KnownFields(true)):

Loader File Status
LoadBenchmarkSpec internal/models/spec.go:226 ✅ strict
GraderConfig.UnmarshalYAML internal/models/spec.go:79 ✅ strict
LoadTestCase internal/models/testcase.go:227 ✅ strict
ValidatorInline.UnmarshalYAML internal/models/testcase.go:103 ✅ strict
DecodeGraderParams internal/models/grader_params.go:252 ✅ strict
trigger.ParseSpec internal/trigger/spec.go:27 ✅ strict
ProjectConfig.Load internal/projectconfig/config.go:203 ✅ strict
jsonrpc eval validate internal/jsonrpc/handlers.go:223 ✅ strict
suggest.validateEvalYAML internal/suggest/suggest.go:336 ✅ strict
suggest.parseSuggestion internal/suggest/suggest.go:202 ✅ strict

Intentionally non-strict (correct):

  • cmd_coverage.go / cmd_check.go — partial struct parses that only read subset of eval.yaml fields
  • internal/generate — skill frontmatter (documented: allows extra fields for other tools)
  • internal/skill — frontmatter generic/node parse
  • internal/validation/schema.go — schema probing into any
  • internal/suggest — grader type probing

Changes

  • Added TestLoadTestCase_UnknownFieldRejected — proves that a task YAML with bogus_field: true is rejected
  • Removed broken TestLoadTestCase_FollowUpPrompts — referenced non-existent TestStimulus.FollowUps field, prevented package compilation on main

Testing

go test -mod=readonly ./internal/models/ — PASS

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>
@github-actions github-actions Bot enabled auto-merge (squash) April 21, 2026 19:10
@spboyer spboyer merged commit 29149f6 into main Apr 21, 2026
6 of 7 checks passed
@spboyer spboyer deleted the squad/132-yaml-validation branch April 21, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WAZA does not validate input yaml fields.

2 participants