-
Notifications
You must be signed in to change notification settings - Fork 164
fix(BA-4108): Use model_validate for health check info to apply Pydantic defaults
#8389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ide class Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where the initial_delay field in health check configurations was being passed as None when missing from YAML, preventing Pydantic from applying its default value of 60.0. The fix replaces manual object construction with Pydantic's model_validate method, which properly applies field defaults.
Changes:
- Replaced manual
ModelHealthCheckconstruction withmodel_validate()to properly handle missing optional fields - Added comprehensive test coverage for health check configurations with various field combinations
- Updated changelog to document the fix
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/ai/backend/manager/registry.py |
Replaced manual construction of ModelHealthCheck with model_validate() to properly apply Pydantic defaults for missing fields |
tests/unit/manager/test_registry.py |
Added comprehensive test suite for health check configurations, including test cases for missing initial_delay field and other optional fields |
changes/8389.fix.md |
Added changelog entry documenting the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
changes/8389.fix.md
Outdated
| @@ -0,0 +1 @@ | |||
| Use `model_validate` for health check info to apply Pydantic defaults, preventing pydantic validation error when `initial_delay` field is nullable | |||
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description says "when initial_delay field is nullable" but this is inaccurate. The issue is that initial_delay is NOT nullable (it's typed as float, not float | None), which is why passing None prevented Pydantic from using its default value. Consider rephrasing to: "preventing pydantic validation error when initial_delay field is missing from the YAML"
| Use `model_validate` for health check info to apply Pydantic defaults, preventing pydantic validation error when `initial_delay` field is nullable | |
| Use `model_validate` for health check info to apply Pydantic defaults, preventing pydantic validation error when `initial_delay` field is missing from the YAML |
…antic defaults (#8389) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Backported-from: main (26.1) Backported-to: 26.1 Backport-of: 8389
resolves #8354 (BA-4108)
Checklist: (if applicable)
ai.backend.testdocsdirectory