← Back to issue list

Poor error reporting for bases earlier than 24

View original Github issue

Metadata

Project
snapcraft
Number
#5613
Type
issue
State
open
Author
dilyn-corner
Labels
Status: Triaged Type: Enhancement
Created
Updated
Closed

Current evaluation

Snapcraft 8.x crashes with a raw traceback (TypeError: 'NoneType' object is not iterable) instead of a friendly error when an empty/None grammar field (e.g. build-packages:) is used on core22 and earlier bases; core24 reports a proper error. Triaged as an enhancement, internal ticket SNAPCRAFT-1186 created, no fix yet.

Suggested action: keep open

Reason: A maintainer (@mr-cal) explicitly triaged this as a real UX bug ('this is not a good user experience... Snapcraft should be more robust when processing grammar') and it was synced to internal ticket SNAPCRAFT-1186, so it is acknowledged and valid. The root cause is still present in the code: snapcraft/parts/grammar.py passes unprocessed_grammar (which is None for an empty key) straight into craft_grammar's GrammarProcessor.process, which does `for section in grammar` and raises TypeError. It is not stale-irrelevant since core22 is still supported and the code path is unchanged.

Impact: 45 Quick Win: 27.0 Staleness: 55 Complexity: 40 Confidence: 70 Support Request: 10

Issue body

### Bug Description If something horrifically unexpected happens in a YAML snapcraft will throw a traceback instead of reporting a proper error. Specifically, snapcraft will usefully tell me that I have some bad snapcraft.yaml content and what was expected when building `base: core24` snaps. However, a traceback is thrown instead of I use `base: core22` snaps. ### To Reproduce Install snapcraft 8.x (using 8.10.y myself) and: ``` mkdir t && cd t; snapcraft init echo 'build-packages:' >> snap/snapcraft.yaml snapcraft sed -i 's/core24/core22/' snap/snapcraft.yaml snapcraft ``` ### Environment Ubuntu 25.04, snapcraft 8.x, building with LXD. ### snapcraft.yaml ```yaml name: test # you probably want to 'snapcraft register <name>' base: core22 # the base snap is the execution environment for this snap version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' summary: Single-line elevator pitch for your amazing snap # 79 char long summary description: | This is my-snap's description. You have a paragraph or two to tell the most important story about your snap. Keep it under 100 words though, we live in tweetspace and your description wants to look good in the snap store. grade: devel # must be 'stable' to release into candidate/stable channels confinement: devmode # use 'strict' once you have the right plugs and slots parts: my-part: # See 'snapcraft plugins' plugin: nil build-packages: ``` ### Relevant log output ```shell dilyn@Ares:~/test -> sc Starting snapcraft, version 8.10.0.post45 Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20250714-150700.168675.log' Bad snapcraft.yaml content: - input should be a valid list (in field 'parts.snapcraft/core.build-packages') dilyn@Ares:~/test -> hx snap/snapcraft.yaml dilyn@Ares:~/test -> sc Starting snapcraft, version 8.10.0.post45 Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20250714-150707.652601.log' Running on amd64 for amd64Traceback (most recent call last): File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/application.py", line 467, in main return app.run() ^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/craft_application/application.py", line 615, in run return_code = self._run_inner() ^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/application.py", line 178, in _run_inner return_code = super()._run_inner() ^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/craft_application/application.py", line 561, in _run_inner dispatcher = self._get_dispatcher() ^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/application.py", line 405, in _get_dispatcher self._check_for_classic_fallback() File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/application.py", line 317, in _check_for_classic_fallback raise errors.ClassicFallback() snapcraft.errors.ClassicFallback During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/snap/snapcraft/x19/bin/snapcraft", line 8, in <module> sys.exit(main()) ^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/application.py", line 470, in main return cli.run() ^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/cli.py", line 256, in run _run_dispatcher(dispatcher, global_args) File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/cli.py", line 229, in _run_dispatcher dispatcher.run() File "/snap/snapcraft/x19/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 528, in run return self._loaded_command.run(self._parsed_command_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/commands/core22/lifecycle.py", line 272, in run super().run(parsed_args) File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/commands/core22/lifecycle.py", line 145, in run parts_lifecycle.run(self.name, parsed_args) File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/parts/lifecycle.py", line 95, in run yaml_data_for_arch = yaml_utils.apply_yaml(yaml_data, build_on, build_for) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/parts/yaml_utils.py", line 203, in apply_yaml yaml_data["parts"] = grammar.process_parts( ^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/parts/grammar.py", line 77, in process_parts process_part(part_yaml_data=part, processor=processor) File "/snap/snapcraft/x19/lib/python3.12/site-packages/snapcraft/parts/grammar.py", line 47, in process_part processed_grammar: list[Any] | None = processor.process( ^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/x19/lib/python3.12/site-packages/craft_grammar/_processor.py", line 89, in process for section in grammar: TypeError: 'NoneType' object is not iterable ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 27.0
Staleness: 55
Complexity: 40
Confidence: 70
Support Request: 10
keep open Snapcraft 8.x crashes with a raw traceback (TypeError: 'NoneType' object is not iterable) instead of a friendly error when an empty/None grammar field (e.g. build-packages:) is used on core22 and earlier bases; core24 reports a proper error. Triaged as an enhancement, internal ticket SNAPCRAFT-1186 created, no fix yet.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 45
Confidence: 75
Support Request: 10
keep open Snapcraft throws a traceback instead of a clear error when using base: core22 with malformed YAML. Triaged as enhancement, acknowledged by maintainer, but inactive for ~1 year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 30
Confidence: 85
Support Request: 0
keep open Snapcraft throws a traceback instead of a clear error when using base: core22 with malformed YAML. Triaged and acknowledged by a maintainer, but inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 60
Complexity: 35
Confidence: 85
Support Request: 5
keep open Snapcraft throws a traceback instead of a clear error message when parsing malformed YAML with bases older than core24. Triaged and acknowledged as a UX enhancement, awaiting implementation to improve grammar validation error reporting.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.