Default `charm` or `bundle` part is not added if `parts` is defined but empty in `charmcraft.yaml`.
Metadata
Current evaluation
Closed without a fix. Maintainers noted the behavior was original design and deferred resolution until charm and bundle parts are refactored into extensions. The issue remains pending for future architectural changes.
Suggested action: —
No scores available.
Issue body
### Bug Description
Currently, the default charm part is added to the charmcraft project configuration using the Pydantic model validator `charmcraft.models.project.CharmcraftProject.preprocess_parts`. However, because Pydantic validators are executed in the order they are defined, and the `parts` field is defined in the parent class `craft_application.models.project.Project` while the `type` field is defined in the child class, the validator for `parts` field will always execute before validator for `type` field.
This means the `type` attributes will never exist in the `values` parameter of `preprocess_parts` validator function. This causes the `parts` not to be added if the `parts` in the charmcraft project file are defined as `{}`. However, when the `parts` field is not defined in `charmcraft.yaml`, its value will be `None`, and the default value of `charmcraft.models.project.BasesCharm.parts` will take effect, setting the parts to `{"charm": {"plugin": "charm", "source": "."}}`.
### To Reproduce
To reproduce this issue, create a `charmcraft.yaml` with the following parts. It will not execute the `charm` part when packed:
```
parts: {}
```
### Environment
Ubuntu 22.04 LTS
### charmcraft.yaml
```shell
name: charm
type: charm
bases:
- build-on:
- name: ubuntu
channel: "22.04"
run-on:
- name: ubuntu
channel: "22.04"
summary: A test charm.
description: A test charm.
# important
parts: {}
```
### Relevant log output
```shell
n/a
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without a fix. Maintainers noted the behavior was original design and deferred resolution until charm and bundle parts are refactored into extensions. The issue remains pending for future architectural changes. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a fix. Maintainers noted the behavior was original design and requires further design work for charm and bundle extensions. The issue was deferred pending redesign, with a workaround suggested but not implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a fix. Maintainer noted the behavior was original design and proposed redesigning charms and bundles as extensions instead. The issue was superseded by planned architectural changes. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without a fix. Maintainers noted the behavior was original design and deferred resolution to future work on making charm and bundle extensions. No code changes were implemented. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without a fix. Maintainers noted the behavior matched the original design and proposed refactoring charms and bundles as extensions. The issue was superseded by planned architectural changes. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2528 docs: Status of `parts` field in `charmcraft.yaml` is misleading | charmcraft | open | charmcraft.yaml reference docs label the `parts` field as 'Recommended', but it is actually required for newer bases (PlatformCharm model enforces min_length=1). Triaged by maintainers; fix deferred to a comprehensive charmcraft.yaml reference review before Kitbash lands. Doc still says 'Recommended' in current main. |