← Back to issue list

Snap revision should use a Pydantic model

View original Github issue

Metadata

Project
craft-providers
Number
#784
Type
issue
State
closed
Author
bepri
Labels
Type: Enhancement
Created
Updated
Closed

Current evaluation

Fixed by merged PR #908 (e996996), adding Pydantic SnapdResponse and SnapInfo models for validated snapd API responses.

Resolution: closed resolved

Reason: PR #908 merged as commit e996996 and replaced assumptions about raw snapd JSON with typed Pydantic validation. The snap installer now uses SnapdResponse and SnapInfo, providing the requested runtime validation and type hints.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### What needs to get done The below code requires assuming the structure of JSON: https://github.com/canonical/craft-providers/blob/5717e2c0907c2bb304d0d3752671be68e9b1fa14/craft_providers/actions/snap_installer.py#L154 It should instead make use of a Pydantic model to assert the structure of the snapd API's response. ### Why it needs to get done To harden the code by validating the response of the snapd API and allowing typehints for developers.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #908 (e996996), adding Pydantic SnapdResponse and SnapInfo models for validated snapd API responses.
stealth/space-bunny-alpha — closed resolved Merged PR #908 added Pydantic SnapInfo and SnapdResponse models to validate snapd API responses, replacing raw JSON deserialization in snap installer handling.
qwen/qwen3.6-35b-a3b — — Closed without implementation. A maintainer approved a volunteer to implement a Pydantic model for snapd API response validation, but no pull request was submitted. The enhancement remains unresolved.
qwen/qwen3.6-35b-a3b — — Accepted and assigned for implementation. A contributor was approved to replace raw JSON parsing with a Pydantic model for snapd API validation, using PR #908 as a reference template.
qwen3.6-35b-a3b-mtp-q6 — — Abandoned. The enhancement requested replacing manual JSON parsing with a Pydantic model for snapd API responses. A developer volunteered and was approved, but no pull request was submitted before closure.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-providers#908 (confidence 96%)

    Merged PR adding the Pydantic models and updating snap installer response handling.

Related issues

Issue Project State Summary Similarity
#783 Snap info should use a Pydantic model craft-providers closed Snapd snap metadata now uses a Pydantic SnapInfo model, merged in PR #908 at commit e996996.
80%
#908 feat(models): add SnapInfo model for snapd response craft-providers merged Merged PR #908 as commit e996996, adding a Pydantic SnapInfo model, optional publisher handling, and tests for snapd responses; fixes #783.
78%
#939 feat(models): add SnapdResponse model for snapd Response craft-providers merged Merged #939 as 2702b5a, adding a Pydantic SnapdResponse model and tests to fix #784. The reported macOS CI failure was confirmed as unrelated flakiness.
76%
#252 snap_installer: move snap pydantic model craft-providers merged Merged PR #252 in commit 0791361, moving the Snap Pydantic model so it can be used across multiple bases.
72%