fix: handle Gemini 'deductions' key alias and fix Pydantic v2 list validation - #416
Open
Prajeeth-12 wants to merge 1 commit into
Open
Conversation
…t validation - Add model_validator to Deductions that normalizes 'deductions' key to 'reasons' before validation, preventing ValidationError crash - Make 'reasons' field optional with empty string default for robustness - Replace Pydantic v1 min_items/max_items with v2 min_length/max_length on key_strengths and areas_for_improvement fields Fixes interviewstreet#349
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.
Fixes #349
Summary
"deductions"as the key name instead of"reasons"inside the deductions object, causing aValidationError: Field required [type=missing]crash. Added amodel_validator(mode="before")that normalizes the key before validation.min_items/max_itemsonkey_strengthsandareas_for_improvementare Pydantic v1 syntax, silently ignored in v2. Replaced withmin_length/max_length.Changes
models.py:model_validatorfrom pydantic@model_validator(mode="before")toDeductionsthat mapsdeductions→reasonsreasonsfield default to""for robustness when neither key is presentField(min_items=1, max_items=5)withField(min_length=1, max_length=5)Test plan
tests/deductions_model_test.py— 5 assertions:reasonskeydeductionsas alias (the Gemini case)reasonstakes priority when both keys presentkey_strengthsschema enforces min/max length (Pydantic v2 validation active)