{"record":{"id":"d7af6841b5036b88","repo":"docker/cli","slug":"invalid-context-no-metadata-found","errorCode":null,"errorMessage":"invalid context: no metadata found","messagePattern":"invalid context: no metadata found","errorType":"validation","errorClass":"invalidParameter","httpStatus":null,"severity":"error","filePath":"cli/context/store/store.go","lineNumber":429,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := s.CreateOrUpdate(meta); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\timportedMetaFile = true\n\t\t} else if strings.HasPrefix(hdr.Name, \"tls/\") {\n\t\t\tdata, err := io.ReadAll(tr)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := importEndpointTLS(&tlsData, hdr.Name, data); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif !importedMetaFile {\n\t\treturn invalidParameter(errors.New(\"invalid context: no metadata found\"))\n\t}\n\treturn s.ResetTLSMaterial(name, &tlsData)\n}\n\nfunc importZip(name string, s Writer, reader io.Reader) error {\n\tbody, err := io.ReadAll(&limitedReader{R: reader, N: maxAllowedFileSizeToImport})\n\tif err != nil {\n\t\treturn err\n\t}\n\tzr, err := zip.NewReader(bytes.NewReader(body), int64(len(body)))\n\tif err != nil {\n\t\treturn err\n\t}\n\ttlsData := ContextTLSData{\n\t\tEndpoints: map[string]EndpointTLSData{},\n\t}\n\n\tvar importedMetaFile bool","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/store/store.go#L411-L447","documentation":"Returned by importTar after iterating every entry in a tarball: if no entry named meta.json (the metaFile) was found, the archive has no context metadata and cannot be imported. Docker contexts require a meta.json file describing endpoints and configuration.","triggerScenarios":"Calling store.Import on a tar stream that lacks a 'meta.json' entry — e.g. importing an arbitrary tarball, a truncated/corrupt export, or an archive whose metadata entry was renamed or placed in a subdirectory.","commonSituations":"Importing a tarball that was not produced by docker context export; a partial file transfer that dropped the metadata entry; manually editing the archive and deleting meta.json; using the wrong file as the import source.","solutions":["Re-export the context from the original host with docker context export and import that file.","Inspect the tarball with tar -tf <file> and confirm a top-level 'meta.json' entry exists.","If the metadata entry is nested under a subdirectory, repackage the archive so meta.json sits at the archive root."],"exampleFix":"// before: docker context import myctx < random.tar  # no meta.json inside\n// after:  docker context export orig; docker context import myctx < orig.dockercontext","handlingStrategy":"validation","validationCode":"// Pre-check that a tar archive contains meta.json before importing\nfunc tarHasMeta(r io.Reader) (bool, error) {\n\ttr := tar.NewReader(r)\n\tfor {\n\t\thdr, err := tr.Next()\n\t\tif err == io.EOF { return false, nil }\n\t\tif err != nil { return false, err }\n\t\tif hdr.Typeflag == tar.TypeReg && path.Clean(hdr.Name) == \"meta.json\" {\n\t\t\treturn true, nil\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source context archives from docker context export.","Verify with 'tar -tf file | grep meta.json' before importing.","Treat a missing metadata entry as a corrupt/incomplete archive rather than retrying blindly."],"tags":["context","import","tar","metadata"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}