{"record":{"id":"b0b0f01789f6a76f","repo":"theonedev/onedev","slug":"invalid-manifest-schema-version","errorCode":null,"errorMessage":"Invalid manifest schema version","messagePattern":"Invalid manifest schema version","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"server-plugin/server-plugin-pack-container/src/main/java/io/onedev/server/plugin/pack/container/ContainerManifest.java","lineNumber":19,"sourceCode":"package io.onedev.server.plugin.pack.container;\n\nimport com.fasterxml.jackson.databind.JsonNode;\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport io.onedev.server.OneDev;\n\nimport org.jspecify.annotations.Nullable;\nimport java.io.IOException;\n\npublic class ContainerManifest {\n\t\n\tprivate final JsonNode json;\n\t\n\tpublic ContainerManifest(byte[] manifestBytes) {\n\t\ttry {\n\t\t\tjson = OneDev.getInstance(ObjectMapper.class).readTree(manifestBytes);\n\t\t\tvar schemaVersionNode = json.get(\"schemaVersion\");\n\t\t\tif (schemaVersionNode == null || !schemaVersionNode.asText().equals(\"2\"))\n\t\t\t\tthrow new BadRequestException(\"Invalid manifest schema version\");\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n\t\n\t@Nullable\n\tpublic String getMediaType() {\n\t\tvar mediaTypeNode = json.get(\"mediaType\");\n\t\tif (mediaTypeNode != null)\n\t\t\treturn mediaTypeNode.asText();\n\t\telse if (json.get(\"config\") != null)\n\t\t\treturn \"application/vnd.oci.image.manifest.v1+json\";\n\t\telse if (json.get(\"manifests\") != null)\n\t\t\treturn \"application/vnd.oci.image.index.v1+json\";\n\t\telse \n\t\t\treturn null;\n\t}\n\t","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-container/src/main/java/io/onedev/server/plugin/pack/container/ContainerManifest.java#L1-L37","documentation":"ContainerManifest's constructor parses an OCI/Docker image manifest and throws BadRequestException when the JSON has no 'schemaVersion' field or its value is not the string \"2\". Valid Docker/OCI manifests must declare schemaVersion 2; anything else is rejected as an unsupported manifest.","triggerScenarios":"Pushing or fetching an image whose manifest lacks schemaVersion or declares version 1 — e.g. images built by very old Docker versions, or manually crafted manifest JSON posted to the container registry endpoints.","commonSituations":"Legacy Docker (pre-1.10) image formats; tools generating manifests by hand with wrong field type (2 as number vs required asText().equals(\"2\")); corrupted or truncated manifest payloads.","solutions":["Rebuild/re-push the image with a modern Docker/OCI-compatible tool (docker build + push)","Regenerate the manifest so it includes \"schemaVersion\": \"2\" and a valid manifest body","If crafting manifests manually, match the schema exactly (schemaVersion as value 2)","Use a manifest-aware tool (e.g. crane manifest) to inspect and fix the stored manifest"],"exampleFix":"// before\n{\"mediaType\":\"application/vnd.docker.distribution.manifest.v2+json\"}\n// after\n{\"schemaVersion\": 2, \"mediaType\":\"application/vnd.docker.distribution.manifest.v2+json\", ...}","handlingStrategy":"validation","validationCode":"const manifest = JSON.parse(fs.readFileSync('manifest.json','utf8'));\nif (String(manifest.schemaVersion) !== '2') throw new Error('manifest schemaVersion must be 2');","typeGuard":"function hasSchemaV2(m) { return m != null && typeof m === 'object' && String(m.schemaVersion) === '2'; }","tryCatchPattern":"try { await pushManifest(manifest); } catch (e) { if (/Invalid manifest schema version/.test(e.message)) { /* regenerate manifest with schemaVersion 2 */ } }","preventionTips":["Use modern docker/buildx to generate manifests","Never hand-write manifest JSON without schemaVersion","Inspect stored manifests with crane/skopeo","Rebuild legacy images before pushing"],"tags":["docker","oci","manifest","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}