← Back to issue list

Unhelpful errors for missing package information keys

View original Github issue

Metadata

Project
rockcraft
Number
#997
Type
issue
State
closed
Author
medubelko
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

Missing required base now produces a clear validation error; fixed by merged PR #1004 in commit d35c0828.

Resolution: closed resolved

Reason: Merged PR #1004, commit d35c0828, made base a required top-level field so its absence reports a validation error instead of an internal AttributeError or KeyError.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description ## Situation When Rockcraft validates the project file, the errors it provide are inconsistent depending on the key. For example, if `name` is omitted, it prints: ``` Bad rockcraft.yaml content: - field 'name' required in top-level configuration ``` But if `base` is absent, it prints: ``` rockcraft internal error: AttributeError("'NoneType' object has no attribute 'count'") ``` It's impossible to identify the issue from that message. Related to #182. ## Request For the mandatory top-level/metadata/package information keys, we should be providing better validation messages. Those are the most critical for publication and least likely to have actual validation errors. ### To Reproduce Pack the provided project file. ### Environment Ubuntu 24.04. ### rockcraft.yaml ```yaml name: test # see https://documentation.ubuntu.com/rockcraft/en/1.14.0/explanation/bases/ # for more information about bases and using 'bare' bases for chiselled rocks version: '0.1' # just for humans. Semantic versioning is recommended # base: ubuntu@24.04 summary: Single-line elevator pitch for your amazing rock # 79 char long summary description: | This is empty's description. You have a paragraph or two to tell the most important story about it. Keep it under 100 words though, we live in tweetspace and your description wants to look good in the container registries out there. platforms: # the platforms this rock should be built on and run on amd64: parts: my-part: plugin: nil ``` ### Relevant log output ```shell 2025-10-10 11:05:55.253 rockcraft internal error: AttributeError("'NoneType' object has no attribute 'count'") 2025-10-10 11:05:55.257 Traceback (most recent call last): 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/application.py", line 650, in run 2025-10-10 11:05:55.257 return_code = self._run_inner() 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/application.py", line 627, in _run_inner 2025-10-10 11:05:55.257 return_code = dispatcher.run() or os.EX_OK 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run 2025-10-10 11:05:55.257 return self._loaded_command.run(self._parsed_command_args) 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/commands/base.py", line 200, in run 2025-10-10 11:05:55.257 result = self._run(parsed_args, **kwargs) or result 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 591, in _run 2025-10-10 11:05:55.257 return super()._run(parsed_args=parsed_args, step_name=step_name) 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 204, in _run 2025-10-10 11:05:55.257 self._run_manager_for_build_plan(fetch_service_policy) 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 95, in _run_manager_for_build_plan 2025-10-10 11:05:55.257 for build in self._services.get("build_plan").plan(): 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/services/buildplan.py", line 64, in plan 2025-10-10 11:05:55.257 self.__plan = self.create_build_plan( 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/services/buildplan.py", line 161, in create_build_plan 2025-10-10 11:05:55.257 self._gen_exhaustive_build_plan(project_data=raw_project), 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_application/services/buildplan.py", line 81, in _gen_exhaustive_build_plan 2025-10-10 11:05:55.257 return craft_platforms.get_build_plan( 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_platforms/_build.py", line 62, in get_build_plan 2025-10-10 11:05:55.257 return planner(**args) 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_platforms/rock/_build.py", line 59, in get_rock_build_plan 2025-10-10 11:05:55.257 return _platforms.get_platforms_build_plan(base, platforms, build_base) 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_platforms/_platforms.py", line 53, in get_platforms_build_plan 2025-10-10 11:05:55.257 distro_base = _distro.DistroBase.from_str(build_base or base) 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-10-10 11:05:55.257 File "/snap/rockcraft/3591/lib/python3.12/site-packages/craft_platforms/_distro.py", line 184, in from_str 2025-10-10 11:05:55.257 if base_str.count("@") != 1: 2025-10-10 11:05:55.257 ^^^^^^^^^^^^^^ ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Missing required base now produces a clear validation error; fixed by merged PR #1004 in commit d35c0828.
stealth/space-bunny-alpha — closed resolved Missing base now produces a clear required-field validation error; fixed by merged PR #1004 (commit d35c0828).
stealth/space-bunny-alpha — closed resolved Missing base now yields a clear required-field validation error instead of an internal exception, via merged PR #1004 (d35c0828).
stealth/space-bunny-alpha — closed resolved Missing base now produces a clear required-field validation error instead of an internal exception; fixed by merged PR canonical/rockcraft#1004 in commit d35c0828.
stealth/space-bunny-alpha — closed resolved Missing base now produces a clear required-field validation error instead of an internal exception; fixed by merged PR #1004 (commit d35c0828).
stealth/space-bunny-alpha — closed resolved Missing required base now returns a clear validation error instead of an AttributeError or KeyError. Fixed by merged PR #1004 in commit d35c0828.
stealth/space-bunny-alpha — closed resolved Missing required base now returns a validation error instead of an internal AttributeError or KeyError. Fixed by merged PR #1004 (d35c0828).
qwen/qwen3.6-35b-a3b — — Fixed by PR #1004. Missing mandatory base key now correctly returns a validation error instead of an internal AttributeError or KeyError. The issue was closed after confirming the improved error message.
qwen/qwen3.6-35b-a3b — — Fixed via PR #1004. Rockcraft now catches missing mandatory keys like base during validation, replacing unhelpful internal AttributeError and KeyError crashes with clear error messages specifying the required field.
qwen/qwen3.6-35b-a3b — — Fixed by merging PR #1004. The update replaces unhelpful internal errors with clear validation messages for missing mandatory keys in rockcraft.yaml, such as field base required in top-level configuration.
qwen3.6-35b-a3b-mtp-q6 — — Resolved via PR #1004. Missing base key no longer triggers an internal AttributeError or KeyError. Validation now correctly outputs field base required in top-level configuration, matching other mandatory field checks.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/rockcraft#1004 (confidence 100%)

    PR #1004 directly fixed the missing-base validation error and was merged as commit d35c0828.

Related issues

No related issues found above the similarity threshold.