Loading project YAML can result in an ugly error if the file is invalid
Metadata
Current evaluation
Invalid project YAML now produces clearer YamlError diagnostics instead of exposing raw PyYAML errors. Fixed by merged PR canonical/craft-application#427 (df906c31).
Resolution: closed resolved
Reason: PR canonical/craft-application#427 was merged with commit df906c31, wrapping YAML parsing failures in user-friendly YamlError diagnostics.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
An invalid yaml file will result in a pyyaml errors being passed all the way to the user. `util.safe_yaml_load` should intercept this and replace it with a nicer error message.
See: https://discourse.charmhub.io/t/charmcraft-3-1-1-fails-to-fetch-lib/14993
### To Reproduce
Run a `craft-application` project command on a project with an invalid yaml file (2 examples for charmcraft below)
### part yaml
```shell
# Example charmcraft.yaml 1:
---
---
# Example 2:
type:
- charm
- invalid-indentation
```
### Relevant log output
```shell
Example 1:
$ charmcraft fetch-lib
charmcraft internal error: ComposerError('expected a single document in the stream', <yaml.error.Mark object at 0x7629eb7c4610>, 'but found another document', <yaml.error.Mark object at 0x7629eb7c4610>)
Full execution log: '/home/lengau/.local/state/charmcraft/log/charmcraft-20240808-112442.474598.log'
Example 2:
$ charmcraft fetch-lib
charmcraft internal error: ParserError('while parsing a block mapping', <yaml.error.Mark object at 0x70b7301f4700>, "expected <block end>, but found '<block sequence start>'", <yaml.error.Mark object at 0x70b7301f4df0>)
Full execution log: '/home/lengau/.local/state/charmcraft/log/charmcraft-20240808-112635.246408.log'
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Invalid project YAML now produces clearer YamlError diagnostics instead of exposing raw PyYAML errors. Fixed by merged PR canonical/craft-application#427 (df906c31). | |
| stealth/space-bunny-alpha | — | closed resolved | Invalid project YAML now gets wrapped, user-friendly diagnostics instead of raw PyYAML errors. Fixed by merged PR canonical/craft-application#427 (df906c31). | |
| stealth/space-bunny-alpha | — | closed resolved | Invalid project YAML errors are now wrapped with clearer messages by merged PR #427 (commit df906c31). | |
| qwen/qwen3.6-35b-a3b | — | — | Closed and tracked internally via Jira CRAFT-3186. A reference to existing error handling utilities was provided, but no repository fix or merge was implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a direct fix. A Jira ticket was created to track the improvement, and a reference to existing error handling code was provided. The issue remains abandoned. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-application#427
(confidence 100%)
Merged fix that explicitly resolves the raw PyYAML error handling described in issue #407.
Related issues
No related issues found above the similarity threshold.