← Back to issue list

Bad error handling for ill-formatted platforms

View original Github issue

Metadata

Project
craft-application
Number
#1217
Type
issue
State
open
Author
cmatsuoka
Labels
Status: Triaged Type: Bug
Created
Updated
Closed
—

Current evaluation

Crash with AttributeError when platforms is declared as a list instead of a dict in snapcraft.yaml. Triaged, with a developer interested in fixing it.

Suggested action: keep open

Reason: Valid, triaged bug with a clear reproducer (platforms as a list causes AttributeError in _vectorise_platforms at craft_application/services/project.py:227). A developer (navyabijoy) has expressed interest in working on it. The fix is straightforward: add type validation in _preprocess_platforms to check that platforms is a dict and raise a helpful CraftValidationError instead of letting the AttributeError propagate.

Evaluated by: mr-cal-bot

Impact: 30 Quick Win: 22 Complexity: 10 Confidence: 80 Actionability: 80

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description A crash trace is displayed if `platforms` members are declared as a list. A nicer, helpful error message should be displayed instead. ### Steps to reproduce Create a core26 snapcraft.yaml declaring platforms as a list. ### Environment core26 managed build with stable snapcraft (9.1.4) ### snapcraft.yaml ```yaml platforms: - amd64: - arm64: ``` ### Log output ```shell $ snapcraft pack --verbose Traceback (most recent call last): File "/snap/snapcraft/19274/bin/snapcraft", line 12, in <module> sys.exit(main()) ^^^^^^ File "/snap/snapcraft/19274/lib/python3.12/site-packages/snapcraft/application.py", line 358, in main return app.run() ^^^^^^^^^ File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/application.py", line 557, in run self._initialize_craft_parts() File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/application.py", line 657, in _initialize_craft_parts self._set_plugin_group() File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/application.py", line 639, in _set_plugin_group build_plan = self.services.get("build_plan").plan() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/services/buildplan.py", line 64, in plan self.__plan = self.create_build_plan( ^^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/services/buildplan.py", line 144, in create_build_plan raw_project["platforms"] = project_service.get_platforms() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/services/project.py", line 286, in get_platforms self.__platforms = self._preprocess_platforms(raw_project["platforms"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/services/project.py", line 260, in _preprocess_platforms cls._vectorise_platforms(platforms) File "/snap/snapcraft/19274/lib/python3.12/site-packages/craft_application/services/project.py", line 227, in _vectorise_platforms for name, data in platforms.items(): ^^^^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'items' ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 22
Complexity: 10
Confidence: 80
Actionability: 80
keep open Crash with AttributeError when platforms is declared as a list instead of a dict in snapcraft.yaml. Triaged, with a developer interested in fixing it.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 20
Complexity: 15
Confidence: 90
Actionability: 80
keep open Crash with AttributeError when platforms is declared as a list instead of a mapping; needs a user-friendly error message instead of a traceback.

Update history

Date Change
updated
updated
updated
created

Related work

  • Duplicate Of: snapcraft#6484 (confidence 90%)

    Identical issue reported in snapcraft repo; craft-application is the correct location since the stack trace originates there.

Related issues

Issue Project State Summary Similarity
#6484 Bad error handling for ill-formatted platforms snapcraft open Crash when platforms is incorrectly specified as a list instead of a mapping; requests a user-friendly error message instead of an AttributeError traceback.
79%