Skip to content

fix(cli): resolve NameError in legacy create-eval-set route - #6681

Open
gaurav-gandhi-2411 wants to merge 1 commit into
google:mainfrom
gaurav-gandhi-2411:fix/dev-server-eval-set-legacy-nameerror
Open

fix(cli): resolve NameError in legacy create-eval-set route#6681
gaurav-gandhi-2411 wants to merge 1 commit into
google:mainfrom
gaurav-gandhi-2411:fix/dev-server-eval-set-legacy-nameerror

Conversation

@gaurav-gandhi-2411

Copy link
Copy Markdown

🔴 Required Information

Describe the Bug:
create_eval_set_legacy in dev_server.py constructs the eval set via UserEvalSet(eval_set_id=eval_set_id, eval_cases=[]). UserEvalSet is never imported or defined anywhere in this file or anywhere else in the package. CreateEvalSetRequest.eval_set is typed EvalSet (from ..evaluation.eval_set import EvalSet, already imported at the top of dev_server.py), which is clearly the class that was intended here.

Steps to Reproduce:

  1. Start the dev server (web=True).
  2. POST /dev/apps/{app_name}/eval_sets/{eval_set_id} (the deprecated legacy create-eval-set route).

Expected Behavior: An empty eval set is created, same as the non-legacy POST /dev/apps/{app_name}/eval-sets route.

Observed Behavior: Every call raises unconditionally:

NameError: name 'UserEvalSet' is not defined

This is executable code (a constructor call), not a type annotation, so it isn't deferred by from __future__ import annotations — the route is broken for every caller, unconditionally.

Why this fix

Swap UserEvalSet(...) for EvalSet(...) — the type the surrounding CreateEvalSetRequest model already declares and that's already imported in this file. One line.

A strict-xfail regression test for exactly this bug already existed — test_create_eval_set_legacy_route_creates_eval_set in tests/unittests/cli/test_fast_api.py, added 2026-08-06 (commit 456524d, "test: add unit tests for public symbols that had no coverage") with reason "legacy create-eval-set route references an undefined name". Rather than add a duplicate test, this PR removes the xfail marker so the existing test now runs and passes for real.

Testing Plan

Confirmed on main (before this change): removing the xfail marker alone reproduces the exact NameError above. After the fix, the same test passes.

tests/unittests/cli/test_fast_api.py::test_create_eval_set_legacy_route_creates_eval_set PASSED
tests/unittests/cli/test_fast_api.py: 106 passed, 5 skipped, 1 xfailed (pre-existing, unrelated)

Observation (not a proposal for this PR)

Ruff's F821 (undefined-name) rule is not enabled in this repo's lint config — pyproject.toml sets [tool.ruff] lint.select = ["F401"] only — which is why this went uncaught by CI. Noting this as context for why the bug shipped, not proposing a CI/config change here.

create_eval_set_legacy in dev_server.py constructed an EvalSet via
UserEvalSet(...), a name that is never imported or defined anywhere in
the package. CreateEvalSetRequest.eval_set is typed EvalSet (already
imported in this file), which is the class that was clearly intended.

Every call to the deprecated POST /dev/apps/{app_name}/eval_sets/{eval_set_id}
route crashed unconditionally with NameError: name 'UserEvalSet' is not
defined.

A strict-xfail regression test for exactly this bug already existed
(test_create_eval_set_legacy_route_creates_eval_set, added 2026-08-06),
so this change removes the xfail marker instead of adding a new test.

Note: ruff's F821 (undefined-name) rule is not enabled in this repo's
lint config (pyproject.toml sets lint.select = ["F401"] only), which is
why this went uncaught by CI.
@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants