Skip to content

fix(config): strictly decode eval and selected case YAML - #375

Merged
zpzjzj merged 8 commits into
alibaba:mainfrom
karanb192:fix/reject-unknown-config-keys
Nov 6, 2026
Merged

zpzjzj merged 8 commits into
alibaba:mainfrom
karanb192:fix/reject-unknown-config-keys

Conversation

@karanb192

@karanb192 karanb192 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A misspelled block such as judgez: was silently dropped, allowing a case to run with zero checks and report PASS. The Loader now uses yaml.v3's Decoder.KnownFields(true) to reject unknown fields, including nested struct fields, with the library's field name and line diagnostics.

Refs #365. Changing how genuinely zero-check cases are reported remains outside this PR.

Changes

  • Remove the custom YAML unmarshallers, reflection-based key walker and stored UnknownKeys diagnostics. Config structs decode directly through the strict decoder.
  • Read effective case IDs before selection, retaining filename fallback. Manual runs and run --auto with YAML strictly decode only selected cases.
  • Decode effective top-level keys into map[string]yaml.Node to preserve explicit judge-field presence, including nulls, aliases and merges.
  • Keep validate and list-cases strict across every referenced case. Free-form maps such as engine kwargs and context files still accept arbitrary keys.
  • Add regressions for nested typos, aliases, merges, filtered field-type errors and judge presence. Correct Go E2E fixture strings that used the previously ignored judge.rule_based.must_contain shape to use judge.success.output_contains.any.
  • Document the loading scope and update the changelog.

Behavior changes

  • Unknown fields now fail loading rather than later validation. Nested struct typos and intentional extra keys are rejected too.
  • Excluded cases may contain unknown fields or unrelated field-type errors. Unreadable files, malformed YAML and invalid IDs still prevent selection.
  • Merged judge and judges keys now participate in null and mutual-exclusion validation.
  • Diagnostics use yaml.v3 wording, including Go type names.

Test plan

Verified on ca63bf4, rebased onto ca276f5:

  • make verify passes with zero findings using Go 1.26.10 and the pinned lint tools.
  • go test -race ./... passes (22 packages).
  • Codex plugin unit tests pass (22 tests).
  • go test -tags e2e ./e2e passes with agent CLIs absent from PATH.

Skill regression scripts and model-backed skill evals were not run. No full example-suite validation was performed in this revision.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T04:37:30.550632Z 2553117 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2553117edf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/config/schema.go Resolved
@karanb192
karanb192 force-pushed the fix/reject-unknown-config-keys branch from 3891ccd to c5927ce Compare November 3, 2026 10:46

zpzjzj commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Could we use yaml.v3’s Decoder.KnownFields(true) for unknown-field validation? The current approach fixes the issue, but introduces reflection and custom alias/merge traversal that we would need to maintain alongside the library’s decoding behavior.

I understand that enabling strict mode alone is insufficient: node.Decode() inside the existing UnmarshalYAML methods does not inherit it. We also need to preserve judge-field presence checks and validation of only the selected cases.

Could those responsibilities move into the Loader—reading the metadata needed for filtering first, then strictly decoding selected cases and recording judge-field presence separately? That could avoid storing diagnostics in UnknownKeys and also catch typos in ordinary nested structs.

Could you explain the tradeoff between that approach and the custom top-level validation proposed here?

@karanb192

Copy link
Copy Markdown
Contributor Author

I'd prefer the Loader approach. I kept this patch at the top level to preserve the existing load/filter/validate flow. The cost is maintaining YAML behavior ourselves.

A local probe with the current structs and yaml.v3 confirmed that strict decoding into a defined type without UnmarshalYAML catches the tested top-level/nested typos, aliased keys, and merge lists.

The tradeoffs I'd make explicit are these.

  1. Read effective IDs, retaining the filename fallback, then strictly decode selected cases. This also lets excluded cases with field-type errors pass where today's full load fails.
  2. A separate map[string]yaml.Node preserves null, alias, and merge presence without custom traversal. It also closes the existing merged-judges: null gap, changing validation for those cases.
  3. Strictness reaches nested structs while free-form maps stay open. Errors use yaml.v3's wording, including a Go type name. validate checks every case; list-cases needs an explicit choice about strictness.

I'd rework this PR along those lines, remove UnknownKeys and the reflection walker, and cover those behavior changes with regressions and an example-suite check.

A misspelled top-level block, for example `judgez:` instead of
`judges:`, was dropped while decoding, so validate accepted the file and
the case ran with no judge and passed with zero checks.

EvalConfig and CaseConfig decode through a custom UnmarshalYAML, whose
node.Decode does not inherit a caller's Decoder.KnownFields(true), so a
strict decoder alone would not catch this. Check the top-level keys
against the struct's yaml tags in both UnmarshalYAML methods and report
the line and key. YAML merge keys are still accepted. Nested keys are
not checked by this change.

Refs alibaba#365
Rejecting unknown top-level keys while decoding aborted `run` for a case
the include and exclude filters leave out, although run validates only
the selected cases. It also skipped keys brought in by `<<` merges, so
`<<: {judgez: []}` still slipped through.

Record unknown top-level keys, including those from merge mappings,
aliases and merge lists, while decoding, and report them from
ValidateEvalConfig and ValidateCaseConfig. `validate` reports every
case; `run` reports only the selected ones.
@karanb192
karanb192 force-pushed the fix/reject-unknown-config-keys branch from c5927ce to 970cbf0 Compare November 5, 2026 17:54
@karanb192 karanb192 changed the title fix(config): report unknown top-level keys in eval.yaml and case files fix(config): strictly decode eval and selected case YAML Nov 5, 2026

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 6, 2026
Merged via the queue into alibaba:main with commit 9da02ce Nov 6, 2026
16 checks passed
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.

2 participants