← Back to issue list

project: validate snapcraft yaml before using it (CRAFT-55)

View original Github issue

Metadata

Project
snapcraft
Number
#3526
Type
pull request
State
closed
Author
cjp256
Labels
Created
Updated
Closed

Current evaluation

Merged into master. Moves snapcraft YAML validation to get_project() to prevent errors during extension application and JSON schema checks. Approved by two reviewers.

Suggested action:

No scores available.

Issue body

Multiple places utilize the yaml before it gets checked by conduct_project_sanity_check(). Instead of requiring the sanity check, verify it before returning the Project object in get_project(). The sanity checks can occur later as well. (1) Config may use it to apply extensions on broken yaml. (2) Snap meta assumptions may break when unmarshaling because the JSON schema check hasn't yet happened. LP: 1853682 CRAFT-55 Signed-off-by: Chris Patterson <chris.patterson@canonical.com> - [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [ ] Have you successfully run `./runtests.sh static`? - [ ] Have you successfully run `./runtests.sh tests/unit`? -----

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged into master. Moves snapcraft YAML validation to get_project() to prevent errors during extension application and JSON schema checks. Approved by two reviewers.
qwen3.6-35b-a3b-mtp-q6 Merged into master. Validates snapcraft YAML earlier in the pipeline to prevent errors during extension application and JSON schema checks, resolving CRAFT-55.
qwen3.6-35b-a3b-mtp-q6 Merged into master. Validates snapcraft YAML earlier in get_project() to prevent errors during extension application and JSON schema unmarshaling, resolving CRAFT-55.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#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.
79%
#3633 projects: add project model and validation (CRAFT-763) snapcraft merged Merged into snapcraft/7.0 after approval and CI checks. Added pydantic models and validators for snapcraft.yaml project files, adjusted package layout to prevent cyclic imports, and increased coverage by 2.02%.
77%
#2517 project: ensure yaml load returns a dictionary snapcraft merged Merged fix for SNAPCRAFT-JQ ensuring yaml.load returns an empty dictionary instead of None for empty files. Prevents validation crashes when Snapcraft processes empty YAML. Approved by reviewer and passed all CI checks.
76%
#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.
74%
#1615 schema: improve invalid app, hook, and part errors snapcraft merged 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.
74%
#334 fix: apply yaml transforms first craft-application merged Merged fix ensuring _extra_yaml_transforms execute before project variable evaluation. Resolves snapcraft#4771 by allowing extensions that inject project variables to function correctly. Approved by two reviewers and passed CI checks.
74%
#3654 projects: add grammar validation snapcraft merged Merged after review and CI approval. Adds pydantic validation for snapcraft.yaml grammar using craft-grammar models. A follow-up update was noted to align with a craft-grammar version change that switched grammar entries to lists.
74%
#3814 extensions: use pydantic to validate yaml before expanding snapcraft merged Merged updates implementing pydantic validation for snapcraft.yaml prior to expansion and correcting an underscore-to-hyphen alias mapping. Approved by two reviewers with passing CI checks, advancing core22 architecture support.
74%
#1073 project: snapcraft.yaml in a snap directory snapcraft merged Merged into master. Defaults new projects to place snapcraft.yaml inside a snap directory while retaining support for legacy locations. Approved and passed CI checks.
73%
#2160 many: refactor snapcraft.yaml loading out of load_config snapcraft merged Merged a refactor separating raw snapcraft.yaml loading from validated processing within load_config. Approved by reviewer, passed CI checks, and integrated into master with 95.54% diff coverage.
73%