Skip to content

Word validation errors from the message catalog - #112

Merged
arav-agarwal2 merged 1 commit into
mainfrom
feat/validation-wording
Oct 7, 2026
Merged

arav-agarwal2 merged 1 commit into
mainfrom
feat/validation-wording

Conversation

@arav-agarwal2

Copy link
Copy Markdown
Collaborator

Follow-up to #111. Pydantic validation failures still reached the report in Pydantic's own words, outside the message catalog. Now they come from the catalog too:

Before After
Built-in error Validation error in point.yaml: concurrency — Field required point.yaml, field \concurrency`: required, but missing`
Our validator Validation error in system_desc.json: (top level) — Value error, Conflicting availability values: … system_desc.json: the availability fields disagree (…) plus Fix: …
  • Our validators (19 sites, plus compute_regions) raise messages.Invalid(rule, key, **values) instead of ValueError. The loader reports each one at the field that failed, with that message's fix and spec.
  • Pydantic's built-in errors are worded by a _pydantic catalog section, keyed by Pydantic's error type. Templates can use the error's context values and {input}.
  • Tests check Invalid(...) calls like err(...) calls and fail on any bare raise ValueError under models/. They walk the file models' core schemas so the _pydantic entries exactly match the error types those models can raise. They also run bad files through each loader in strict mode.
  • Not changed: Pydantic skips model-level validators when a field fails, so a cross-field problem still appears only after the field errors are fixed. Fixing that means moving those checks out of the models, which belongs in a separate PR.

Checks

Full suite: 1515 passed. ruff and mypy are clean.

🤖 Generated with Claude Code

Pydantic validation failures reached the report as Pydantic's own text: its
built-in messages ("Field required"), and our validators' hand-written
ValueErrors behind a "Value error," prefix, located at "(top level)" when a
model-level validator failed. None of it was in the catalog.

- Validators raise messages.Invalid(rule, key, **values), a ValueError
  rendered from the catalog; the loaders report it at the field that failed,
  keeping its fix and spec. compute_regions raises it too.
- A _pydantic catalog section words Pydantic's built-in errors by error type,
  using the error's context values and {input}.
- Tests: Invalid calls are checked like err() calls; no bare ValueError may be
  raised under models/; the _pydantic entries must match exactly the error
  types the file models' schemas can produce; and bad files through each
  loader render entirely from the catalog in strict mode.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@arav-agarwal2
arav-agarwal2 merged commit e36265d into main Oct 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant