project: ensure yaml load returns a dictionary
Metadata
Current evaluation
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.
Suggested action: —
No scores available.
Issue body
PyYAML yaml loading and parsing can return None if given an empty file
or empty string. When validating its yaml file, Snapcraft expects the
result to be subscriptable, so return an empty dictionary instead of None.
Fixes SNAPCRAFT-JQ
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
- [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] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged to ensure yaml.load returns an empty dictionary instead of None for empty inputs. This prevents validation failures in Snapcraft by guaranteeing a subscriptable result, resolving SNAPCRAFT-JQ. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Updates PyYAML loading to return an empty dictionary instead of None for empty inputs, preventing validation errors in Snapcraft. Resolves SNAPCRAFT-JQ. Changes passed static checks and unit tests with 100% diff coverage. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #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. | |
| #2781 yaml_utils: move _load_yaml from project for re-use (and add tests) | snapcraft | merged | Merged. Moved _load_yaml to yaml_utils as load_yaml_file, added tests, and improved error handling to raise YamlValidationError. Approved, passed CI, and changed 3 files. Logic will be reused for snapcraft config files. | |
| #1384 Support yaml merge tags | snapcraft | merged | Merged. Fixes snapcraft's YAML loader to support merge tags. Custom dict constructors previously caused parsing failures. The update restores standard PyYAML merge tag handling, approved by two reviewers and passing CI. | |
| #2458 clean: error out on invalid or missing yaml | snapcraft | merged | Merged. Modifies the clean command to fail if snapcraft.yaml is missing or lacks a name field, preventing accidental cleanup of non-snapcraft projects. Resolves LP #1777501. Approved, passed CI, and merged. | |
| #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. | |
| #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. |