You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(BA-5978): make BackendAIModel.build_validation_error overridable
Add a public ``build_validation_error`` classmethod on
``BackendAIModel`` that returns the ``BackendAIError`` instance to
raise when ``model_validate*`` fails. Default surfaces the generic
``BackendAIModelValidationFailed``; subclasses override the method to
inject a domain-specific 400 directly, without any caller-side
try/except re-wrap.
Apply the override on the two models that previously needed wrapping:
* ``ModelDefinition`` raises ``ModelDefinitionValidationError``.
Moved that exception class from ``ai.backend.agent.errors.agent``
to ``ai.backend.common.exception`` (and dropped the agent re-export)
so the model — which lives in ``common.config`` — can construct it
without an upward-layer import. The agent-specific error_type URL
segment is dropped in the move.
* ``SessionSpec`` raises ``IncompleteSessionSpec`` with the existing
``extra_data["missing"]`` shape, using a module-local
``_format_loc`` helper.
The caller-side try/except wrappers around ``ModelDefinition.model_validate``
in ``agent/agent.py`` and ``manager/services/model_card/service.py``,
and the wrapper in
``sokovan/scheduling_controller/preparers/session_spec_preparer.py``,
are all removed — the models now raise the right domain error
directly.
Tests stay unchanged: they still expect ``IncompleteSessionSpec`` /
``ModelDefinitionValidationError`` because the override raises the
same types.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments