← Back to issue list

tests: add reproducer for dev multipass version causing InvalidVersion (#1917)

View original Github issue

Metadata

Project
charmcraft
Number
#2668
Type
pull request
State
open
Author
lengau
Labels
Created
2026-04-22 03:05:50+00:00
Updated
2026-04-22 04:23:46+00:00
Closed

Current evaluation

Resolves a crash from non-PEP-440 multipass version strings by adding a reproducer test and patching ProviderService.instance() to catch InvalidVersion and raise a user-friendly CraftError.

Suggested action: needs review

Reason: The PR contains a clear reproducer test and a straightforward fix that resolves the InvalidVersion crash. It is ready for maintainer code review and merge.

Staleness: 20 Complexity: 10 Confidence: 90

Issue body

## Summary Adds a failing unit test that reproduces #1917: when multipass has a dev version string like `1.15.0-dev.2929.pr661+gc67ef6641.mac`, charmcraft crashes with an unhandled `packaging.version.InvalidVersion` internal error. ## Bug The root cause is in `craft_providers`: `multipass.is_supported_version()` calls `packaging.version.parse()` which raises `InvalidVersion` for non-PEP-440 strings. Charmcraft's `ProviderService.instance()` does not catch this exception, so it propagates as an internal error. Upstream bug: https://github.com/canonical/craft-providers/issues/661 The fix in charmcraft would be to catch `InvalidVersion` in `ProviderService.instance()` and convert it to a user-friendly `CraftError`. ## Reproducer ``` uv run python -m pytest 'tests/unit/services/test_provider.py::test_instance_handles_invalid_multipass_version' -v ``` The test fails with: ``` packaging.version.InvalidVersion: Invalid version: '1.15.0-dev.2929.pr661' ``` Closes #1917

Evaluation history

Date Model Scores Action Summary
2026-06-15 11:38:26.889334+00:00 qwen3.6-35b-a3b-mtp-q6
Staleness: 20
Complexity: 10
Confidence: 90
needs review Resolves a crash from non-PEP-440 multipass version strings by adding a reproducer test and patching ProviderService.instance() to catch InvalidVersion and raise a user-friendly CraftError.
2026-06-15 11:35:47.495499+00:00 pending