fix: use correct error message for invalid version
Metadata
Current evaluation
Merged in canonical/rockcraft#441 (7955ba06), fixing misleading invalid-version errors by removing error_msg_templates and using transform_pydantic_errors; closes #429.
Resolution: closed resolved
Reason: PR #441 was merged as commit 7955ba06. It corrected validation messages for non-name fields while preserving Rockcraft's customized name error and closed issue #429.
Evaluated by: mr-cal-bot
No scores available.
Issue body
**Note:** The first commit bumps craft-application 1.2.0 and fixes a couple of expected messages in tests. I couldn't split this into two PRs because two of the tests (related to name validation) can only pass with the second commit.
-------------
The code refers to the 'name' message, but the bug was due to the
"error_msg_templates" in the Config: it made *every* regex validation
failure use the INVALID_NAME_MESSAGE message, even for those fields that
*aren't* the 'name'.
Since the "error_msg_templates" option is deprecated and gone in
Pydantic 2 anyway, remove it altogether and use the new
transform_pydantic_errors() hook from craft-application to preserve the
customisation of the 'name' field's message. This is necessary because
our 'name' regex is different than the 'name' regex in
craft-application's model (ours is a bit stricter), so we can just use
craft-application's message as that would be misleading.
Fixes #429
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/rockcraft#441 (7955ba06), fixing misleading invalid-version errors by removing error_msg_templates and using transform_pydantic_errors; closes #429. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #441 (7955ba06) removed error_msg_templates and adopted transform_pydantic_errors, fixing invalid-version messages while retaining custom name errors; fixes #429. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #441 at commit 7955ba06, fixing misleading invalid-version errors while preserving the custom name-validation message. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #441 (7955ba06) fixed misleading invalid-version errors by replacing error_msg_templates with craft-application's transform_pydantic_errors hook, resolving #429. | |
| stealth/space-bunny-alpha | — | closed resolved | PR #441 merged as commit 7955ba06, using transform_pydantic_errors so invalid version fields show the correct message while preserving custom name errors; fixes #429. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/rockcraft#441 (7955ba06), replacing error_msg_templates with transform_pydantic_errors so invalid version fields show the correct message while preserving custom name errors. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged after approval. Replaced deprecated error_msg_templates with craft-application's transform_pydantic_errors hook to fix incorrect validation error messages. Resolves #429. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged fix for incorrect validation error messages caused by a deprecated config. Removed the option and implemented craft-application 1.2.0's transform_pydantic_errors hook to correctly route field-specific messages, resolving #429. |
Update history
No update history recorded yet.
Related work
-
Related To:
canonical/rockcraft#429
(confidence 100%)
The misleading invalid-version error report explicitly fixed by PR #441.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #176 parts: fix conversion of PartsError | rockcraft | merged | Merged in canonical/rockcraft#176 (ffeb4c89), fixing PartsError conversion to preserve craft-cli verbosity-based error reporting. |