← Back to issue list

internal errors for platform string

View original Github issue

Metadata

Project
craft-application
Number
#750
Type
issue
State
open
Author
mr-cal
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

testcraft pack crashes with AttributeError when a platform value is a string instead of a dict. The bug is still present in current code; _vectorise_platforms calls data.get() without guarding against str values.

Suggested action: keep open

Reason: The bug is confirmed still present in the current codebase: _vectorise_platforms in craft_application/services/project.py calls data.get("build-for") without checking isinstance(data, str), so a string platform value like 'my-platform: amd64' will still crash with AttributeError. The issue is labeled 'Status: Triaged' and 'Type: Bug', indicating maintainer acknowledgement. No fix commit has been found in the git history addressing this specific case. The fix is straightforward (add a str guard before calling .get()), so it should remain open for resolution.

Impact: 40 Quick Win: 32.0 Staleness: 70 Complexity: 20 Confidence: 85 Support Request: 0

Issue body

### Bug Description Invalid platform that contain a string rather than a dict produce an internal error: ```bash > testcraft pack testcraft internal error: AttributeError("'str' object has no attribute 'get'") Full execution log: '/home/callahan.kovacs@canonical.com/.local/state/testcraft/log/testcraft-20250428-081754.712525.log' ``` ### To Reproduce testcraft pack ### part yaml ```shell name: testcraft version: "0.1" base: ubuntu@24.04 platforms: my-platform: amd64 parts: my-test: plugin: nil ``` ### Relevant log output ```shell 2025-04-28 08:17:54.713 Starting testcraft, version dev 2025-04-28 08:17:54.713 Log verbosity level set to BRIEF 2025-04-28 08:17:54.716 Preparing application... 2025-04-28 08:17:54.716 Merging commands for group 'Lifecycle': 2025-04-28 08:17:54.716 Configuring application... 2025-04-28 08:17:54.716 Setting up ConfigService 2025-04-28 08:17:54.716 App is not running as a snap - snap config handler not created. 2025-04-28 08:17:54.716 Setting up ProjectService 2025-04-28 08:17:54.717 Loading project file '/home/callahan.kovacs@canonical.com/dev/craft/craft-application/testcraft/testcraft.yaml 2025-04-28 08:17:54.719 testcraft internal error: AttributeError("'str' object has no attribute 'get'") 2025-04-28 08:17:54.719 Traceback (most recent call last): 2025-04-28 08:17:54.720 File "/home/callahan.kovacs@canonical.com/dev/craft/craft-application/craft_application/application.py", line 615, in run 2025-04-28 08:17:54.720 return_code = self._run_inner() 2025-04-28 08:17:54.720 ^^^^^^^^^^^^^^^^^ 2025-04-28 08:17:54.720 File "/home/callahan.kovacs@canonical.com/dev/craft/craft-application/craft_application/application.py", line 581, in _run_inner 2025-04-28 08:17:54.720 project_service.configure(platform=platform, build_for=build_for) 2025-04-28 08:17:54.720 File "/home/callahan.kovacs@canonical.com/dev/craft/craft-application/craft_application/services/project.py", line 75, in configure 2025-04-28 08:17:54.720 platforms = self.get_platforms() 2025-04-28 08:17:54.720 ^^^^^^^^^^^^^^^^^^^^ 2025-04-28 08:17:54.720 File "/home/callahan.kovacs@canonical.com/dev/craft/craft-application/craft_application/services/project.py", line 268, in get_platforms 2025-04-28 08:17:54.720 self.__platforms = self._preprocess_platforms(raw_project["platforms"]) 2025-04-28 08:17:54.720 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-04-28 08:17:54.720 File "/home/callahan.kovacs@canonical.com/dev/craft/craft-application/craft_application/services/project.py", line 242, in _preprocess_platforms 2025-04-28 08:17:54.720 cls._vectorise_platforms(platforms) 2025-04-28 08:17:54.720 File "/home/callahan.kovacs@canonical.com/dev/craft/craft-application/craft_application/services/project.py", line 228, in _vectorise_platforms 2025-04-28 08:17:54.720 if data.get("build-for") is None and name in ( 2025-04-28 08:17:54.720 ^^^^^^^^ 2025-04-28 08:17:54.720 AttributeError: 'str' object has no attribute 'get' 2025-04-28 08:17:54.720 Full execution log: '/home/callahan.kovacs@canonical.com/.local/state/testcraft/log/testcraft-20250428-081754.712525.log' ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 40
Quick Win: 32.0
Staleness: 70
Complexity: 20
Confidence: 85
Support Request: 0
keep open testcraft pack crashes with AttributeError when a platform value is a string instead of a dict. The bug is still present in current code; _vectorise_platforms calls data.get() without guarding against str values.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 40
Confidence: 70
Support Request: 0
keep open Internal error when platform config contains a string instead of dict. Issue is triaged as a bug, created by a maintainer, but has been inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 85
Support Request: 5
keep open Bug where an invalid platform configuration (string instead of dict) triggers an internal AttributeError during project parsing. Triaged but inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 0
keep open Internal AttributeError occurs when platform config uses a string instead of a dict. Triaged and linked to CRAFT-4539. Currently inactive and awaiting assignment or development.

Update history

No update history recorded yet.

Related work

  • Related To: craft-application#686 (confidence 60%)

    PR #686 'fix(ProjectService): better handling for invalid platforms' addressed related platform validation issues but did not fix the str-value case that causes this AttributeError.

Related issues

No related issues found above the similarity threshold.