{"record":{"id":"6b7f5ef4da150679","repo":"dagger/dagger","slug":"invalid-image-config-for-export-missing-architect","errorCode":null,"errorMessage":"invalid image config for export: missing architecture","messagePattern":"invalid image config for export: missing architecture","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/engineutil/imageexport/writer.go","lineNumber":466,"sourceCode":"\nfunc patchImageConfig(dt []byte, descs []ocispecs.Descriptor, history []ocispecs.History, inlineCache []byte, epoch *time.Time, baseImg *dockerspec.DockerOCIImage) ([]byte, error) {\n\tvar img ocispecs.Image\n\tif err := json.Unmarshal(dt, &img); err != nil {\n\t\treturn nil, errors.Wrap(err, \"invalid image config for export\")\n\t}\n\n\tm := map[string]json.RawMessage{}\n\tif err := json.Unmarshal(dt, &m); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse image config for patch\")\n\t}\n\tif m == nil {\n\t\treturn nil, errors.Errorf(\"invalid null image config for export\")\n\t}\n\tif img.OS == \"\" {\n\t\treturn nil, errors.Errorf(\"invalid image config for export: missing os\")\n\t}\n\tif img.Architecture == \"\" {\n\t\treturn nil, errors.Errorf(\"invalid image config for export: missing architecture\")\n\t}\n\n\trootFS := ocispecs.RootFS{Type: \"layers\"}\n\tfor _, desc := range descs {\n\t\trootFS.DiffIDs = append(rootFS.DiffIDs, digest.Digest(desc.Annotations[labels.LabelUncompressed]))\n\t}\n\trootJSON, err := json.Marshal(rootFS)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to marshal rootfs\")\n\t}\n\tm[\"rootfs\"] = rootJSON\n\n\tif epoch != nil {\n\t\tvar divergedFromBase bool\n\t\tfor i, h := range history {\n\t\t\tif !divergedFromBase && baseImg != nil && i < len(baseImg.History) && reflect.DeepEqual(h, baseImg.History[i]) {\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/engineutil/imageexport/writer.go#L448-L484","documentation":"patchImageConfig likewise requires a non-empty 'architecture' field; otherwise it returns \"invalid image config for export: missing architecture\". The OCI spec mandates architecture in the image config for the manifest to be usable.","triggerScenarios":"commitPlatformManifest -> patchImageConfig with a config JSON missing 'architecture' or containing an empty string — same root causes as the missing-os case: hand-rolled or minimal configs.","commonSituations":"Scripts generating image configs that set os but forget architecture; programmatic exports supplying partial Image structs; base images from non-conformant build tools.","solutions":["Add \"architecture\": \"amd64\" (or arm64 etc.) to the image config","Populate Platform.Architecture from platforms.DefaultSpec()/Normalize when building configs in code","Rebuild the base image with a conformant toolchain"],"exampleFix":"// before\n{\"os\": \"linux\", \"rootfs\": {\"type\": \"layers\", \"diff_ids\": []}}\n// after\n{\"os\": \"linux\", \"architecture\": \"amd64\", \"rootfs\": {\"type\": \"layers\", \"diff_ids\": []}}","handlingStrategy":"validation","validationCode":"func hasArchitecture(dt []byte) bool {\n  var img ocispecs.Image\n  if json.Unmarshal(dt, &img) != nil { return false }\n  return img.Architecture != \"\"\n}","typeGuard":"func configHasArch(img ocispecs.Image) bool { return img.Architecture != \"\" }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"missing architecture\") {\n  // inject defaults: img.Architecture = platforms.Normalize(platforms.DefaultSpec()).Architecture and retry\n}","preventionTips":["Always set Platform.Architecture when constructing image configs programmatically","Derive architecture from platforms.DefaultSpec()/Normalize instead of omitting it","Run a pre-export check that both os and architecture are present"],"tags":["oci","image-config","validation"],"backgroundTag":"invalid-image-config","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}