{"record":{"id":"6458d890cdf01c9e","repo":"docker/cli","slug":"context-not-found-w","errorCode":null,"errorMessage":"context not found: %w","messagePattern":"context not found: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/store/metadatastore.go","lineNumber":76,"sourceCode":"\t\treturn nil, err\n\t}\n\treturn reflect.ValueOf(typed).Elem().Interface(), nil\n}\n\nfunc (s *metadataStore) get(name string) (Metadata, error) {\n\tm, err := s.getByID(contextdirOf(name))\n\tif err != nil {\n\t\treturn m, fmt.Errorf(\"context %q: %w\", name, err)\n\t}\n\treturn m, nil\n}\n\nfunc (s *metadataStore) getByID(id contextdir) (Metadata, error) {\n\tfileName := filepath.Join(s.contextDir(id), metaFile)\n\tbytes, err := os.ReadFile(fileName)\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\treturn Metadata{}, notFound(fmt.Errorf(\"context not found: %w\", err))\n\t\t}\n\t\treturn Metadata{}, err\n\t}\n\tvar untyped untypedContextMetadata\n\tr := Metadata{\n\t\tEndpoints: make(map[string]any),\n\t}\n\tif err := json.Unmarshal(bytes, &untyped); err != nil {\n\t\treturn Metadata{}, fmt.Errorf(\"parsing %s: %v\", fileName, err)\n\t}\n\tr.Name = untyped.Name\n\tif r.Metadata, err = parseTypedOrMap(untyped.Metadata, s.config.contextType); err != nil {\n\t\treturn Metadata{}, fmt.Errorf(\"parsing %s: %v\", fileName, err)\n\t}\n\tfor k, v := range untyped.Endpoints {\n\t\tif r.Endpoints[k], err = parseTypedOrMap(v, s.config.endpointTypes[k]); err != nil {\n\t\t\treturn Metadata{}, fmt.Errorf(\"parsing %s: %v\", fileName, err)\n\t\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/store/metadatastore.go#L58-L94","documentation":"Returned as an errdefs NotFound error by GetMetadata/getByID when the context's meta.json does not exist on disk. The notFound() wrapper makes it satisfy errdefs.IsNotFound, so callers can distinguish 'missing' from 'broken'.","triggerScenarios":"Calling store.GetMetadata(name) for a name with no directory under the store's meta root: the context was never created, was deleted, or the store root points at the wrong location (e.g. wrong DOCKER_CONFIG).","commonSituations":"Fresh install with only 'default'; typo in name; stale DOCKER_CONTEXT env var; DOCKER_CONFIG pointing at a different config directory; referencing a context removed on another machine via a synced home dir.","solutions":["Create the context (`docker context create <name> ...`) or switch to 'default' (`docker context use default`).","Verify spelling against `docker context ls`.","Confirm DOCKER_CONFIG / the store root points at the directory holding your contexts."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check existence without erroring before GetMetadata.\nfunc contextExists(s store.ReaderLister, name string) (bool, error) {\n    list, err := s.List()\n    if err != nil {\n        return false, err\n    }\n    for _, m := range list {\n        if m.Name == name {\n            return true, nil\n        }\n    }\n    return false, nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := store.GetMetadata(name); err != nil {\n    if errors.Is(err, errdefs.ErrNotFound) {\n        // context is absent — handle gracefully\n    }\n}","preventionTips":["Confirm DOCKER_CONFIG points at the directory holding your contexts.","Use `docker context ls` to verify exact names before scripting against them.","Default to 'default' when an arbitrary name may not exist."],"tags":["context","not-found","docker-engine"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}