← Back to issue list

Charmcraft 3 should still accept image digests for `upload-resource`

View original Github issue

Metadata

Project
charmcraft
Number
#1953
Type
issue
State
open
Author
lengau
Labels
Created
Updated
Closed

Current evaluation

Charmcraft 3 `upload-resource` rejects bare image digests (e.g. sha256:…) that charmcraft 2 accepted; the ImageService lacks a digest-based lookup via RepoDigests. Unlabeled, no maintainer response, only a bot Jira-sync comment.

Suggested action: needs triage

Reason: The issue is a real regression: charmcraft 3's `upload-resource` no longer accepts bare image digests (e.g. `sha256:583ddc…`) that charmcraft 2 supported via PR #871/#908. The current code in `store.py` falls through to the `else` branch because the regex `^[a-z-]+:` doesn't match `sha256:` (digits not in the character class), and `get_maybe_id_from_docker` only handles name/tag lookups, not digest-based lookups via `RepoDigests`. No maintainer has labeled, assigned, or responded to this issue — only an automated Jira-sync bot comment exists — so it needs triage.

Impact: 50 Quick Win: 35.0 Staleness: 55 Complexity: 30 Confidence: 72 Support Request: 0

Issue body

### Bug Description Charmcraft 3 doesn't accept digests, just image IDs, when uploading a resource. Solution: Reimplement [this method](https://github.com/canonical/charmcraft/blob/c13f20ae65b6a4d3657dcdd30b2f606ccae86163/charmcraft/commands/store/registry.py#L314-L342) on the ImageService. It can use Docker's [images.list()](https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.list) method and find the digest under `image.attrs["RepoDigests"]`. Note that these digests are in `<name>@<hash-algo>:<hash>` form, so you'll need to check if it matches a regex something like `".+@([a-z0-9]+:)?{digest}"` (so it works with just the hash or algo:hash). ### To Reproduce See: https://discourse.charmhub.io/t/publish-your-charm-on-charmhub/12281/6?u=lengau ### Environment n/a ### charmcraft.yaml ```yaml n/a ``` ### Relevant log output ```shell $ charmcraft upload-resource loki-worker-k8s loki-image --image=sha256:583ddc10f52bb4fe4806baa05ecbaa2a3246238f1423bd2a6c35b02fd87b446c Unknown OCI image reference. Recommended resolution: Pass a valid container transport string. Full execution log: '/home/jose/.local/state/charmcraft/log/charmcraft-20240801-171905.784405.log' ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 50
Quick Win: 35.0
Staleness: 55
Complexity: 30
Confidence: 72
Support Request: 0
needs triage Charmcraft 3 `upload-resource` rejects bare image digests (e.g. sha256:…) that charmcraft 2 accepted; the ImageService lacks a digest-based lookup via RepoDigests. Unlabeled, no maintainer response, only a bot Jira-sync comment.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 20
Confidence: 90
Support Request: 10
needs triage Charmcraft 3 rejects image digests for upload-resource, only accepting image IDs. Provides a code fix using Docker's image list API. Currently unlabelled and awaiting maintainer triage after over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 30
Confidence: 75
Support Request: 10
needs triage Charmcraft 3 rejects image digests for upload-resource, only accepting image IDs. Requires reimplementing digest resolution in ImageService. Currently unlabelled with no maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 45
Confidence: 75
Support Request: 10
needs triage Charmcraft 3 rejects image digests for upload-resource, only accepting image IDs. The report includes reproduction steps and a proposed fix but lacks labels and maintainer response after over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 80
Complexity: 30
Confidence: 75
Support Request: 10
needs triage Charmcraft 3 rejects image digests for upload-resource, only accepting image IDs. Requires reimplementing digest lookup via Docker's RepoDigests to resolve the Unknown OCI image reference error. Open, unassigned, and awaiting implementation.

Update history

No update history recorded yet.

Related work

  • Caused By: canonical/charmcraft#1696 (confidence 75%)

    PR #1696 rewrote upload-resource to use skopeo and the new ImageService, dropping the old digest-lookup logic from registry.py that used images.list() and RepoDigests.

Related issues

Issue Project State Summary Similarity
#906 `charmcraft upload-resource` 2.1.0 removes ability to pass tagged image names to `--image` argument charmcraft closed Closed as solved. Affected teams migrated CI to use image digests instead of tags. Rather than reverting the change, PR #912 was created to improve error messaging when tagged image names are provided.
73%
#444 unable to upload oci-image resource from dockerhub using image digest charmcraft closed Superseded by charmcraft 1.1.1, which replaces remote digest uploads with local image uploads using digests. Closed as the upcoming release resolves the parsing limitation.
72%
#839 Upload resources on charmcraft upload when specified as upstream-resource in the metadata file charmcraft closed Rejected. Maintainers declined automatic resource uploads to prevent copying third-party images to Canonical's registry and avoid inefficient uploads. Developers should script the process using Charmcraft's CLI.
71%
#912 Make explicit that image resources are not uploadable by tag charmcraft closed Superseded by charmcraft 3. The tool now uses explicit --image-id and --image-digest flags, eliminating the ambiguous --image tag handling and resolving the reported UX issue.
71%