fix(charm): allow colons in platform names without base prefix
Metadata
Current evaluation
Merged PR #194 (commit 39fafcc) fixed charm platform parsing: parse_base_and_name() now only treats a prefix before ':' as a base when it contains '@', so names like '0:' no longer raise ValueError. Closes issue #116.
Resolution: closed resolved
Reason: PR #194 was merged to main as commit 39fafcc, adding an '@' check in parse_base_and_name() plus regression tests for '0:', '123:456' and 'unknown:my-platform'. Issue #116 ('Charm with weird platform name breaks') is closed as fixed by this commit.
Evaluated by: mr-cal-bot
No scores available.
Issue body
## Summary
Fixed platform name parsing issue where names containing colons (e.g., "0:") were incorrectly treated as having a base prefix, causing ValueError.
## Changes Made
- [x] Understand the issue: Platform name "0:" incorrectly treated as base string
- [x] Add test case for platform name "0:" in test_platforms.py
- [x] Fix parse_base_and_name to only treat prefix as base if it contains "@"
- [x] Add test case for charm build plan with "0:" platform
- [x] Run tests to verify the fix (8801 tests pass)
- [x] Run linters to ensure code quality (ruff, mypy)
- [x] Code review passed with no issues
- [x] Security scan passed with no vulnerabilities
- [x] Address review feedback: Fix docstring typo
## Key Change
Updated `parse_base_and_name()` to check if the prefix before ":" contains "@" before treating it as a base string. This allows platform names like "0:" to be treated as valid platform names rather than invalid base specifications.
## Testing
- All 8801 unit tests pass
- Verified exact scenario from issue works correctly
- Tested edge cases (numbers, text, mixed formats)
- Code quality checks pass (ruff formatting and linting, mypy)
- Security scan clean
## Security Summary
No vulnerabilities were discovered during the security scan.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Charm with weird platform name breaks</issue_title>
> <issue_description>A charm with:
>
> ```yaml
> base: ubuntu@24.04
> platforms:
> "0:":
> build-on: [amd64]
> build-for: [amd64]
> ```
>
> Raises `ValueError: Invalid base string '0'. Format should be '<distribution>@<series>'`.
>
> First discovered at https://github.com/canonical/craft-platforms/actions/runs/14137328500/job/39612051861?pr=83#step:6:205</issue_description>
>
> <agent_instructions>Start by writing a test matching the error case. Then write a fix.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes canonical/craft-platforms#116
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for you](https://github.com/canonical/craft-platforms/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #194 (commit 39fafcc) fixed charm platform parsing: parse_base_and_name() now only treats a prefix before ':' as a base when it contains '@', so names like '0:' no longer raise ValueError. Closes issue #116. | |
| qwen/qwen3.6-35b-a3b | — | closed resolved | Fixed platform name parsing to allow colons in names without a base prefix (e.g., "0:") by updating `parse_base_and_name()` to require "@" in the prefix. Merged. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Duplicate Of:
canonical/craft-platforms#116
(confidence 99%)
PR body states 'Fixes canonical/craft-platforms#116', the original issue reporting ValueError for platform name '0:'; that issue is now closed.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #116 Charm with weird platform name breaks | craft-platforms | closed | Fixed by PR #194 (commit 39fafcc): platform parsing now accepts colon-containing names such as "0:" when no base prefix is present. |