Skip to content

fix(config): reject rule_based assertions with no recognizable matcher in validate - #295

Open
BiBoyang wants to merge 1 commit into
alibaba:mainfrom
BiBoyang:fix/validate-recognizable-rule
Open

BiBoyang wants to merge 1 commit into
alibaba:mainfrom
BiBoyang:fix/validate-recognizable-rule

Conversation

@BiBoyang

@BiBoyang BiBoyang commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Reject rule_based assertions that set none of the supported matcher fields. Non-strict YAML parsing silently drops unknown matcher keys, decoding a typo'd assertion (e.g. output_not_contains) to an all-zero Rule that previously passed validation. At runtime such an empty rule fails late with unknown_rule in success position, and no-ops in failure position, letting cases pass with zero assertions evaluated.

Related issues

Closes #294

Changes

  • internal/config/validator.go: validateJudgeTypeAndLocalFields (shared by eval-level and case-level judges, and by run's pre-execution validation via ValidateCasesWithEvalDefaults) now reports an error per empty rule, naming the rule position and listing all supported matchers.
  • internal/config/validator_test.go: empty rules rejected in success/failure at both eval and case level; all 10 matchers (including the four turn-level ones) covered by false-positive-guard cases.
  • CHANGELOG.md: entry under Unreleased / Fixed.

Test plan

  • make test passes
  • make verify passes (fmt + vet + lint)
  • Manual testing steps (if applicable): an eval whose case uses output_not_contains now exits 1 at skill-up validate with judge.success[0]: assertion has no recognizable matcher field; supported matchers: ...; the corrected output_contains: {not: [...]} equivalent still validates.

Notes for reviewers

Zero behavior change for well-formed configs — only assertions that were already silently inert are newly refused. Strict-mode YAML decoding (KnownFields(true)) was considered and left as a follow-up: it is a breaking change for any existing config with stray keys, while this PR only rejects rules that never did anything.

…r in validate

Non-strict YAML parsing silently drops unknown matcher keys, decoding a
typo'd assertion (e.g. output_not_contains) to an all-zero Rule that used
to pass validation. At runtime such an empty rule fails late with
"unknown_rule" in success position, and no-ops in failure position,
letting cases pass with zero assertions evaluated.

Reject empty rules in validateJudgeTypeAndLocalFields so both
`skill-up validate` and `skill-up run` (which validates selected cases
before executing) refuse them with an error listing the supported
matchers.

This branch has not been deployed

No deployments
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.

validate accepts rule_based assertions with unknown matcher names — typo'd failure rules silently become no-ops

1 participant