Skip to content

fix: handle Gemini 'deductions' key alias and fix Pydantic v2 list validation - #416

Open
Prajeeth-12 wants to merge 1 commit into
interviewstreet:mainfrom
Prajeeth-12:fix/349-pydantic-deductions-validation
Open

fix: handle Gemini 'deductions' key alias and fix Pydantic v2 list validation#416
Prajeeth-12 wants to merge 1 commit into
interviewstreet:mainfrom
Prajeeth-12:fix/349-pydantic-deductions-validation

Conversation

@Prajeeth-12

Copy link
Copy Markdown

Fixes #349

Summary

  • Deductions model crash: Gemini sometimes returns "deductions" as the key name instead of "reasons" inside the deductions object, causing a ValidationError: Field required [type=missing] crash. Added a model_validator(mode="before") that normalizes the key before validation.
  • Pydantic v2 list constraints: min_items/max_items on key_strengths and areas_for_improvement are Pydantic v1 syntax, silently ignored in v2. Replaced with min_length/max_length.

Changes

  • models.py:
    • Import model_validator from pydantic
    • Add @model_validator(mode="before") to Deductions that maps deductionsreasons
    • Make reasons field default to "" for robustness when neither key is present
    • Replace Field(min_items=1, max_items=5) with Field(min_length=1, max_length=5)

Test plan

  • tests/deductions_model_test.py — 5 assertions:
    • Accepts standard reasons key
    • Accepts deductions as alias (the Gemini case)
    • reasons takes priority when both keys present
    • Missing both keys uses empty string default
    • key_strengths schema enforces min/max length (Pydantic v2 validation active)
$ python tests/deductions_model_test.py
All tests passed!

…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
Copilot AI lite review requested due to automatic review settings August 26, 2026 13:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Gemini provider crashes with a Pydantic validation error on deductions.reasons

2 participants