Skip to content

evals: single-EvalCase guard reads type hints, runtime matches values — a fixture returning an EvalCase bypasses it #120

Description

@renaudcepre

Context

_validate_single_evalcase_param walks the function's type hints at decorator time (wrapper.py:143-156), while _find_case matches on runtime values with isinstance(v, EvalCase) over all kwargs (wrapper.py:164-169).

A parameter annotated as something else (e.g. Annotated[Database, Use(db)]) whose fixture happens to return an EvalCase instance is invisible to the registration guard, but visible to _find_case — which silently picks whichever comes first in kwargs order. The carefully built loud error (MultipleEvalCaseParamsError) can thus be bypassed by the exact scenario it exists to prevent.

Impact

Edge case, but the failure is the bad kind: wrong case name/expected/inputs attributed to the eval, no error anywhere.

Suggestion

Make _find_case defensive: if more than one kwarg value is an EvalCase, raise MultipleEvalCaseParamsError at runtime too (same error, second line of defense, mirrors the registration/runtime pairing used elsewhere).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiDependency injectionevalsEvals layer (wrapper, evaluators, scoring)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions