open-component-model / ocm-project

OCM Project Backlog
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

Open frewilhelm opened 3 months ago

frewilhelm commented 3 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 week 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.