YAML structure is not validated before preprocessing
Metadata
Current evaluation
Fixed in PR #5728 (commit 3f076004f): malformed app mappings are skipped during extension preprocessing, allowing a schema error instead of an AttributeError.
Resolution: closed resolved
Reason: PR #5728 was merged in commit 3f076004f, adding defensive type checks around unvalidated app data. Full pre-validation was rejected because extensions must run before Pydantic validation and may add or constrain keys.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
The included snapcraft.yaml throws an exception: `snapcraft internal error: AttributeError("'list' object has no attribute 'get'")` It's valid YAML syntax but there's a semantic mistake: the `plugs` section is not properly indented under a single app.
### To Reproduce
Run `snapcraft pack` against the provided YAML.
### Environment
Ubuntu 24.04
### snapcraft.yaml
```yaml
name: test
base: core24
apps:
test-app:
command: test-part
plugs:
- home
- network
```
### Relevant log output
```shell
2025-08-12 12:52:23.383 snapcraft internal error: AttributeError("'list' object has no attribute 'get'")
2025-08-12 12:52:23.385 Traceback (most recent call last):
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/application.py", line 623, in run
2025-08-12 12:52:23.385 return_code = self._run_inner()
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/snapcraft/application.py", line 184, in _run_inner
2025-08-12 12:52:23.385 return_code = super()._run_inner()
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/application.py", line 602, in _run_inner
2025-08-12 12:52:23.385 return_code = dispatcher.run() or os.EX_OK
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run
2025-08-12 12:52:23.385 return self._loaded_command.run(self._parsed_command_args)
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/commands/base.py", line 200, in run
2025-08-12 12:52:23.385 result = self._run(parsed_args, **kwargs) or result
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/snapcraft/commands/lifecycle.py", line 74, in _run
2025-08-12 12:52:23.385 super()._run(parsed_args)
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 575, in _run
2025-08-12 12:52:23.385 return super()._run(parsed_args=parsed_args, step_name=step_name)
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 190, in _run
2025-08-12 12:52:23.385 self._run_manager_for_build_plan(fetch_service_policy)
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 96, in _run_manager_for_build_plan
2025-08-12 12:52:23.385 provider.run_managed(build, bool(fetch_service_policy))
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/services/provider.py", line 432, in run_managed
2025-08-12 12:52:23.385 with self.instance(
2025-08-12 12:52:23.385 File "/usr/lib/python3.12/contextlib.py", line 137, in __enter__
2025-08-12 12:52:23.385 return next(self.gen)
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/services/provider.py", line 159, in instance
2025-08-12 12:52:23.385 project_name = self._services.get("project").get().name
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/services/project.py", line 528, in get
2025-08-12 12:52:23.385 self._project_model = self.render_for(
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/services/project.py", line 473, in render_for
2025-08-12 12:52:23.385 project = self._preprocess(
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/.venv/lib/python3.12/site-packages/craft_application/services/project.py", line 445, in _preprocess
2025-08-12 12:52:23.385 self._app_preprocess_project(
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/snapcraft/services/project.py", line 55, in _app_preprocess_project
2025-08-12 12:52:23.385 apply_extensions(project, arch=build_on, target_arch=build_for)
2025-08-12 12:52:23.385 File "/home/steinbro/can/snapcraft/snapcraft/extensions/_utils.py", line 42, in apply_extensions
2025-08-12 12:52:23.385 extension_names = app_definition.get("extensions", [])
2025-08-12 12:52:23.385 ^^^^^^^^^^^^^^^^^^
2025-08-12 12:52:23.385 AttributeError: 'list' object has no attribute 'get'
```
### Additional context
The issue is that the `apply_extensions` method under snapcraft/extension/_utils.py assumes a specific YAML structure before it has been validated.
Interestingly, the zed text editor does show this as a syntax error, because it autodetected the specific YAML format and validates against the snapcraft JSON schema available at https://www.schemastore.org/. Would a robust fix to this issue be to do the same validation before trying to apply any preprocessing?
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed in PR #5728 (commit 3f076004f): malformed app mappings are skipped during extension preprocessing, allowing a schema error instead of an AttributeError. | |
| stealth/space-bunny-alpha | — | closed not a bug | The proposed schema-first validation was rejected: extensions must run before Pydantic validation because they can add or forbid keys. Closed without a verified linked code fix. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a fix. Maintainers noted preprocessing must run before schema validation because extensions dynamically add required keys. Early validation would break extensions, making the crash an unavoidable architectural constraint. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as by design. Pre-validation was rejected because extensions must modify the YAML before schema validation. The fix requires making the preprocessing logic robust to handle malformed structures gracefully instead of validating first. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed. Maintainers declined the request, noting extension preprocessing must run before validation since extensions dynamically modify the schema and inject required keys. The current flow is intentional. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Rejected. Maintainers closed the issue, explaining that extensions must be applied before schema validation since they dynamically modify the YAML structure. The preprocessing order remains unchanged. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/snapcraft#5728
(confidence 100%)
Merged fix for YAML schema errors that crashed extension preprocessing, including the reported case.
Related issues
No related issues found above the similarity threshold.