theonedev/onedev · error · BadRequestException
Invalid manifest schema version
Error message
Invalid manifest schema version
What it means
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.
Source
Thrown at server-plugin/server-plugin-pack-container/src/main/java/io/onedev/server/plugin/pack/container/ContainerManifest.java:19
package io.onedev.server.plugin.pack.container;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.onedev.server.OneDev;
import org.jspecify.annotations.Nullable;
import java.io.IOException;
public class ContainerManifest {
private final JsonNode json;
public ContainerManifest(byte[] manifestBytes) {
try {
json = OneDev.getInstance(ObjectMapper.class).readTree(manifestBytes);
var schemaVersionNode = json.get("schemaVersion");
if (schemaVersionNode == null || !schemaVersionNode.asText().equals("2"))
throw new BadRequestException("Invalid manifest schema version");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Nullable
public String getMediaType() {
var mediaTypeNode = json.get("mediaType");
if (mediaTypeNode != null)
return mediaTypeNode.asText();
else if (json.get("config") != null)
return "application/vnd.oci.image.manifest.v1+json";
else if (json.get("manifests") != null)
return "application/vnd.oci.image.index.v1+json";
else
return null;
}
View on GitHub (pinned to d44925c47c)
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
Example fix
// before
{"mediaType":"application/vnd.docker.distribution.manifest.v2+json"}
// after
{"schemaVersion": 2, "mediaType":"application/vnd.docker.distribution.manifest.v2+json", ...} Defensive patterns
Strategy: validation
Validate before calling
const manifest = JSON.parse(fs.readFileSync('manifest.json','utf8'));
if (String(manifest.schemaVersion) !== '2') throw new Error('manifest schemaVersion must be 2'); Type guard
function hasSchemaV2(m) { return m != null && typeof m === 'object' && String(m.schemaVersion) === '2'; } Try / catch
try { await pushManifest(manifest); } catch (e) { if (/Invalid manifest schema version/.test(e.message)) { /* regenerate manifest with schemaVersion 2 */ } } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Unknown collection element class (bean: X, property: Y)
- Property 'type' is reserved (class: X)
- Dependency property not found: X
- Unsupported type: X
- Loopback address not allowed for target docker image of push
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/b0b0f01789f6a76f.
Report an issue: GitHub.