[APO-2934] Make _parse_ml_models resilient to validation errors#3702
[APO-2934] Make _parse_ml_models resilient to validation errors#3702dvargas92495 merged 2 commits intomainfrom
Conversation
Co-Authored-By: vargas@vellum.ai <vargas@vellum.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: vargas@vellum.ai <vargas@vellum.ai>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a80df6a4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| try: | ||
| parsed_models.append(MLModel.model_validate(item)) | ||
| except Exception as e: | ||
| model_name = item.get("name") if isinstance(item, dict) else None | ||
| logger.warning(f"Skipping ML model '{model_name}' due to validation error: {type(e).__name__}") |
There was a problem hiding this comment.
Limit exception handling to validation errors
Catching Exception here will silently skip models on any unexpected error raised inside MLModel.model_validate, including programming errors or runtime issues unrelated to input validation. That can mask real regressions (e.g., a bug in validation logic) by downgrading them to warnings and dropping models, which makes failures harder to detect. Since the intent is only to ignore validation failures, consider catching the specific Pydantic validation exception(s) instead.
Useful? React with 👍 / 👎.
Makes
_parse_ml_modelsinBaseWorkflowDisplayresilient to validation errors by catching exceptions for individual models, skipping invalid ones, and logging warnings instead of failing the entire serialization process.