schema: improve invalid app, hook, and part errors
Metadata
Current evaluation
Merged changes improve validation error messages for invalid app, hook, and part names in snapcraft.yaml. Replaces confusing jsonschema errors with custom validation messages, resolving Launchpad bug #1606890. Approved by two reviewers and passed CI.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
Currently, when one attempts to use an invalid app, hook, or part name, rather than saying something about it being an invalid name because it didn't match the regex, jsonschema uses the `additionalProperties` validator, which makes the error message extra awful, e.g.:
Issues while validating snapcraft.yaml: The 'apps' property does not match the required schema: Additional properties are not allowed ('invalid_app_name' was unexpected)
This PR fixes LP: [#1606890](https://bugs.launchpad.net/snapcraft/+bug/1606890) by improving these messages, adding custom in-schema validation errors for them instead of relying on jsonschema.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged changes improve validation error messages for invalid app, hook, and part names in snapcraft.yaml. Replaces confusing jsonschema errors with custom validation messages, resolving Launchpad bug #1606890. Approved by two reviewers and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Replaced jsonschema's generic additionalProperties error messages with custom validation errors for invalid app, hook, and part names in snapcraft.yaml, improving user feedback. Fixes Launchpad bug #1606890. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged improvements to error messages for invalid app, hook, and part names in snapcraft.yaml. Replaces generic jsonschema additionalProperties errors with custom validation messages, resolving Launchpad bug #1606890. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #296 Improve snapcraft.yaml validation errors. | snapcraft | merged | Merged improvements to snapcraft.yaml validation error messages. Replaces cryptic jsonschema outputs with clear messages for missing or invalid icons, apparmor, and seccomp profiles. Approved by reviewers and integrated into the codebase. | |
| #1622 schema: sync patterns with snapd | snapcraft | merged | Synced snap name and hook name patterns with snapd, resolving LP bug #1693798. Improved jsonschema error handling readability. Merged after reviewer approval and passing CI checks. | |
| #3526 project: validate snapcraft yaml before using it (CRAFT-55) | snapcraft | closed | Merged into master. Moves snapcraft YAML validation to get_project() to prevent errors during extension application and JSON schema checks. Approved by two reviewers. | |
| #419 Properly validate the schema | snapcraft | merged | Merged refactoring that consolidates schema validation logic and removes it from snapcraft.yaml. The changes were finalized after fixing failing autopackage tests and addressing reviewer feedback. | |
| #5924 docs: clean up 'snapcraft.yaml' | snapcraft | merged | Merged documentation cleanup for snapcraft.yaml, including typo fixes, docstring link updates, and JSON schema regeneration. Reviewers approved the non-functional changes, and the schema workflow was resolved by running make schema. | |
| #1957 schema: improve the snap name's validator | snapcraft | merged | Merged schema validator improvements. Fixed exponential regex performance, added length validation, and clarified error messages. Approved by two reviewers, modified two files, and aligns with project-wide validation unification. | |
| #2388 project: early snapcraft.yaml validation | snapcraft | merged | Merged. Implements early snapcraft.yaml validation to prevent invalid multipass instance creation and reduce build times. Approved by maintainer, passed CI checks, and resolved Launchpad bug #1794507. |