open-component-model / ocm-project

OCM Project Backlog
https://ocm.software/
Apache License 2.0
0 stars 0 forks source link

Add a clear error message that an ambiguous tag is not supported when adding resources of type `ociImage` #229

Closed frewilhelm closed 1 day ago

frewilhelm commented 4 months ago

Description   Adding a resource of type ociImage that is tagged with latest returns the following error:  

$ ocm add resource $CA_ARCHIVE --type ociImage --name image --version ${VERSION} --accessType ociArtifact --reference gcr.io/google_containers/echoserver:latest
processing resource (by options)...
  processing document 1...
    processing index 1
found 1 resource
adding resource ociImage: "name"="image","version"="1.0.0"...
Error: cannot add resource "image"(resource (by options)[1][1]): cannot determine digest: oci artifact "gcr.io/google_containers/echoserver:latest" not found in google_containers/echoserver

(inspired by this example)

Using the same command without an unambiguously tag, e.g. 1.10, resolves the error.   It is reasonable that it is not possible to add an image with the tag latest as a resource, as the tag can never uniquely reference a resource. However, the error message is confusing, as it is not clear that the tag is the problem.  


That is why I would propose a clear and precise error message that the tag latest is not supported.   However, one could also argue that this part of the error message cannot determine digest: is sufficient to indicate that the resource cannot be referenced unambiguously.


Done Criteria

morri-son commented 1 month ago

However, one could also argue that this part of the error message cannot determine digest: is sufficient to indicate that the resource cannot be referenced unambiguously.

Errors should as clearly as possible state what is the issue and directly point to the cause. It is fine to give more information and an explanation in addition, but at first hand there should be "the tag latest is not supported in a resource definition.

jakobmoellerdev commented 1 day ago

I took a look here and TBH i dont understand why its impossible to determine a digest. It should be able to resolve from latest to the currently fetched sha256 digest and use that as a reference IMO. WDYT?

frewilhelm commented 1 day ago

I mistakenly assumed that gcr also resolves a latest tag. This is not the case. There is no latest tag at all. So the issue is unnecessary.