fix(eval): default RubricContent.text_property to None so rubrics save without 422 - #7026
Open
ALDRIN121 wants to merge 1 commit into
Open
fix(eval): default RubricContent.text_property to None so rubrics save without 422#7026ALDRIN121 wants to merge 1 commit into
ALDRIN121 wants to merge 1 commit into
Conversation
…e without 422 RubricContent.text_property was typed Optional[str] but had no default. Under Pydantic v2 an Optional field without a default is still required, so saving an eval case whose rubric omits text_property failed model validation and the PUT returned HTTP 422 — the same required-Optional trap that google#6515 fixed for InvocationEvent.content but left unaddressed here. Default it to None so an omitted or empty text_property is accepted and round-trips through the GET(exclude_none=True) -> PUT cycle. Related google#7019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a Pydantic-v2 "required Optional" trap that makes saving an eval case fail with HTTP 422 when a rubric's
text_propertyis omitted or empty.RubricContent.text_propertyis typedOptional[str]but has no default. Under Pydantic v2, anOptionalfield without a default is still required — so when the Web UI'sGETserializes an eval case withresponse_model_exclude_none=True(droppingtext_property: None) and the browser re-submits it on the savePUT, the field is missing and validation fails with422 Unprocessable Entity.This is the exact same bug class as #6336 / the #6515 fix (
fix: make InvocationEvent.content optional so the Web UI can save eval cases), which patchedInvocationEvent.contentbut leftRubricContent.text_propertyunaddressed. Related to #7019 (422 persists across 2.6.0–2.8.0 despite #6515).Root cause
src/google/adk/evaluation/eval_rubrics.py:Fix
Default
text_propertytoNone, matching the acceptedInvocationEvent.contentfix:Reproduction (before the fix)
After the fix, the round-trip succeeds and
text_propertyisNone.Testing plan
pytest tests/unittests/evaluation/test_eval_case.py— 24 passed (2 new tests:test_rubric_content_text_property_defaults_to_none,test_eval_case_with_rubric_missing_text_property_round_trips).pytest tests/unittests/evaluation/test_rubric_based_tool_use_quality_v1.py— passed (no regression in rubric consumers).Note: I ran the focused evaluation tests; the broader
tests/unittests/evaluation/suite requires optional GCS/Vertex deps not installed in the minimal venv.Signed-off-by: Aldrin Joseph yoaldrinjoseph@gmail.com