Fix for getting image info from digest
Metadata
Current evaluation
Merged PR #908 fixes OCI image lookup when Docker returns RepoDigests as None, adds a regression test, and clarifies upload-resource image ID help text.
Resolution: closed resolved
Reason: PR #908 was merged in commit a9b7a7a9, resolving the NoneType TypeError and documenting the expected image identifier format.
Evaluated by: mr-cal-bot
No scores available.
Issue body
I have consistently encountered an error when trying to upload an OCI image resource by digest,
```
2022-10-19 18:48:50.975 Checking if manifest is already uploaded
2022-10-19 18:48:54.748 Remote image not found, getting its info from local registry.
2022-10-19 18:48:54.752 charmcraft internal error: TypeError("'NoneType' object is not iterable")
2022-10-19 18:48:54.757 Traceback (most recent call last):
2022-10-19 18:48:54.757 File "/snap/charmcraft/1083/lib/charmcraft/main.py", line 180, in main
2022-10-19 18:48:54.757 retcode = dispatcher.run()
2022-10-19 18:48:54.757 File "/snap/charmcraft/1083/lib/craft_cli/dispatcher.py", line 448, in run
2022-10-19 18:48:54.757 return self._loaded_command.run(self._parsed_command_args)
2022-10-19 18:48:54.757 File "/snap/charmcraft/1083/lib/charmcraft/commands/store/__init__.py", line 1778, in run
2022-10-19 18:48:54.757 image_info = dockerd.get_image_info_from_digest(parsed_args.image)
2022-10-19 18:48:54.757 File "/snap/charmcraft/1083/lib/charmcraft/commands/store/registry.py", line 335, in get_image_info_from_digest
2022-10-19 18:48:54.757 if any(digest in repo_digest for repo_digest in image_info["RepoDigests"]):
2022-10-19 18:48:54.757 TypeError: 'NoneType' object is not iterable
```
and it seems that the request to the docker daemon returns a `None` object when the `RepoDigests` key is empty. This is often the case for any images that have been built locally.
This PR adds a simple fix and test for that.
Then with the recent [change](https://github.com/canonical/charmcraft/pull/871/files) in handling the upload of OCI image resources, I thought it would be helpful to describe exactly what should be included in the ID of an image, originally I was including the "sha26:" portion and that was what was leading me to encountering the bug above. So I've also tweaked the help text output from `charmcraft upload-resource`
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #908 fixes OCI image lookup when Docker returns RepoDigests as None, adds a regression test, and clarifies upload-resource image ID help text. | |
| stealth/space-bunny-alpha | — | closed resolved | PR #908 was merged, fixing the None RepoDigests TypeError and clarifying upload-resource help text; implementation commit a9b7a7a9. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged fix for TypeError when retrieving image info by digest due to None RepoDigests. Added tests and updated upload-resource help text. Approved by reviewers and passed CI checks. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged fix preventing a TypeError when uploading OCI images by digest. The change safely handles None values in RepoDigests for locally built images and updates charmcraft upload-resource help text to clarify image ID formatting. |
Update history
No update history recorded yet.
Related work
-
Related To:
canonical/charmcraft#871
(confidence 90%)
Earlier OCI image upload handling change referenced as context for the image ID clarification.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #853 The upload-resource command should accept images id or digests | charmcraft | closed | Merged PR #871 resolved support for OCI image IDs and digests in upload-resource, improving local ID handling and missing-image errors. |