Skip to content

Commit 1cc790c

Browse files
authored
Better error message when getting legacy manifests (#600)
Signed-off-by: Valentin Delaye <jonesbusy@users.noreply.github.com>
1 parent 0a714ba commit 1cc790c

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/land/oras/OCI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ protected boolean isIndexMediaType(String mediaType) {
231231
*/
232232
protected boolean isManifestMediaType(String mediaType) {
233233
return mediaType.equals(Const.DEFAULT_MANIFEST_MEDIA_TYPE)
234-
|| mediaType.equals(Const.DOCKER_MANIFEST_MEDIA_TYPE);
234+
|| mediaType.equals(Const.DOCKER_MANIFEST_MEDIA_TYPE)
235+
|| mediaType.equals(Const.LEGACY_MANIFEST_MEDIA_TYPE);
235236
}
236237

237238
/**

src/main/java/land/oras/Registry.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ public Manifest getManifest(ContainerRef containerRef) {
691691
throw new OrasException(
692692
"Expected manifest but got index. Probably a multi-platform image instead of artifact");
693693
}
694+
if (contentType.equals(Const.LEGACY_MANIFEST_MEDIA_TYPE)) {
695+
throw new OrasException(
696+
"Schema version 1 with manifest media type '%s' is not supported. Please use schema version 2 or higher"
697+
.formatted(contentType));
698+
}
694699
String json = descriptor.getJson();
695700
String digest = descriptor.getDigest();
696701
if (digest == null) {

src/main/java/land/oras/utils/Const.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ private Const() {
163163
*/
164164
public static final String DEFAULT_INDEX_MEDIA_TYPE = "application/vnd.oci.image.index.v1+json";
165165

166+
/**
167+
* Legacy manifest media type for Docker distribution manifest v1, which is a JWS (JSON Web Signature) format and is not widely used anymore, but some registries may still support it for backward compatibility
168+
* Ensure to raise a proper error message when we encounter this media type, as it is not supported by the SDK
169+
*/
170+
public static final String LEGACY_MANIFEST_MEDIA_TYPE = "application/vnd.docker.distribution.manifest.v1+prettyjws";
171+
166172
/**
167173
* The artifact manifest media type
168174
*/

0 commit comments

Comments
 (0)