diff --git a/CHANGELOG.md b/CHANGELOG.md index 98415cbf..05b20f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Copy fixture contents when `context.repo_fixture` names a directory symlink in the `none` and OpenSandbox runtimes. Local uploads no longer fail with a directory read error, and OpenSandbox no longer silently uploads an empty fixture. +- Reject YAML `.nan` as a judge pass threshold during validation. No pass + rate can meet that threshold. - Reject a `rule_based` matcher that is present but holds no values to match. `output_contains: {all: []}`, `output_matches: {}`, `turn_response_contains` without `contains_all`/`contains_any`, and `turn_response_not_contains` diff --git a/internal/config/validator.go b/internal/config/validator.go index 27317ae6..f1935739 100644 --- a/internal/config/validator.go +++ b/internal/config/validator.go @@ -562,7 +562,7 @@ func validatePassThreshold(threshold *float64) []string { if threshold == nil { return nil } - if *threshold < 0.0 || *threshold > 1.0 { + if math.IsNaN(*threshold) || *threshold < 0.0 || *threshold > 1.0 { return []string{"judge.pass_threshold must be between 0.0 and 1.0"} } return nil diff --git a/internal/config/validator_test.go b/internal/config/validator_test.go index 3029beec..b21d1a07 100644 --- a/internal/config/validator_test.go +++ b/internal/config/validator_test.go @@ -3,8 +3,24 @@ package config import ( "strings" "testing" + + "gopkg.in/yaml.v3" ) +func TestValidateEvalConfigRejectsNaNPassThreshold(t *testing.T) { + t.Parallel() + cfg := DefaultEvalConfig() + cfg.Cases.Files = []string{"case.yaml"} + cfg.Judge = JudgeConfig{Type: judgeTypeAgentJudge, Model: "test-model", Criteria: []string{"check"}} + if err := yaml.Unmarshal([]byte("pass_threshold: .nan"), &cfg.Judge); err != nil { + t.Fatal(err) + } + err := NewValidator().ValidateEvalConfig(cfg) + if err == nil || !strings.Contains(err.Error(), "judge.pass_threshold") { + t.Fatalf("ValidateEvalConfig() error = %v, want invalid pass_threshold", err) + } +} + func TestEnvironmentAgentHome(t *testing.T) { for _, kind := range []string{runtimeTypeNone, runtimeTypeDocker, runtimeTypeOpenSandbox} { for _, mode := range []string{"", "inherited", "temporary", "unknown"} {