config: migrate to use pydantic BaseModel
Metadata
Current evaluation
Merged in canonical/charmcraft#323 via commit a68601fa, replacing JSON Schema validation with Pydantic BaseModel and adding Config.unmarshal() and clearer field-based errors.
Resolution: closed resolved
Reason: PR #323 was approved and merged through commit a68601fa. Its implementation commit, ae4402a1, migrated configuration validation from JSON Schema to Pydantic BaseModel.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- Drop json schema in favor of BaseModel's validations
- Add unmarshal() interface to Config to handle unmarshaling the
yaml object.
- Since `type` is not allowed to be None, set to "no-charmcraft-yaml"
when there is no YAML.
- Add a minimal Parts() and Part() implementation to allow for
parts.bundle.prime definition. This should ultimately be replaced
with a reference to the implementation in craft-parts.
- Minor logging message changes:
- must be a full URL -> must be a fully qualified URL
- must be a valid relative URL -> must be a valid relative path
- Errors are now output as a list, with fields represented with
python-like notation. Lists items are indexed with [n] and
dictionary items are reduced to the key. For example:
```
Bad charmcraft.yaml content:
- field: <broken-field>
reason: <some reason>
- field: <parts.bundle>
reason: <some reason>
- field: <broken.field_list[3]>
reason: <some reason>
- ...
```
...where:
- "bundle" is the object key under parts
- "field_list[3]" is indicating the third element in field_list
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/charmcraft#323 via commit a68601fa, replacing JSON Schema validation with Pydantic BaseModel and adding Config.unmarshal() and clearer field-based errors. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in #323 (a68601fa), replacing JSON Schema validation with Pydantic BaseModel, adding Config.unmarshal(), and revising configuration validation and error reporting. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #323 replaced JSON Schema validation with Pydantic BaseModel, added Config.unmarshal() and basic parts handling, and improved validation error output. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged after approval and CI checks. Migrated configuration handling to Pydantic BaseModel, replacing JSON schema with native validations. Added an unmarshal interface, updated error formatting, and implemented basic Parts handling. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged config migration to Pydantic BaseModel, replacing JSON schema with native validations. Added unmarshal() interface, updated error formatting, fixed logging messages, and added minimal Parts support. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1768 Migrate to Pydantic 2 | charmcraft | closed | Migrated Charmcraft to Pydantic 2 via merged PR #1777 (70078b03), with the feature branch merged to main in #1817 (394e6e55). | |
| #1141 pydantic: split base and charmcraft config models | charmcraft | merged | Merged as commit 17ad0211: common Pydantic models moved to basic.py, and the Charmcraft config moved to charmcraft.py and renamed CharmcraftConfig. |