{"record":{"id":"ac472f636720f874","repo":"docker/cli","slug":"context-q-w","errorCode":null,"errorMessage":"context %q: %w","messagePattern":"context %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/store/metadatastore.go","lineNumber":66,"sourceCode":"\t}\n\tif getter == nil {\n\t\tvar res map[string]any\n\t\tif err := json.Unmarshal(payload, &res); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn res, nil\n\t}\n\ttyped := getter()\n\tif err := json.Unmarshal(payload, typed); err != nil {\n\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 {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/store/metadatastore.go#L48-L84","documentation":"Top-level wrapper returned by ContextStore.GetMetadata() for any failure looking up a context by name. It wraps the underlying getByID error — most often the not-found error (504) but also any parse or I/O failure — and includes the context name for diagnostics.","triggerScenarios":"Calling store.GetMetadata(name) where name has no directory (wraps not-found), or where the context's meta.json is corrupt/unreadable (wraps a parse/IO error).","commonSituations":"Typo in context name; referencing a context after `docker context rm`; corrupted context directory; shell completion or scripts probing arbitrary names.","solutions":["Run `docker context ls` to confirm the exact context name exists.","If the inner error is 'context not found', create or switch to an existing context (`docker context use default`).","If the inner error is a parse/IO error, inspect meta.json on disk or recreate the context."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"meta, err := store.GetMetadata(name)\nif err != nil {\n    // GetMetadata wraps the underlying cause with the context name.\n    if errors.Is(err, errdefs.ErrNotFound) {\n        // missing context — create or fall back\n    }\n    return err\n}","preventionTips":["List existing contexts before assuming a name exists.","Unwrap the error (errors.Is) to distinguish not-found from corruption rather than string-matching.","Validate the name with ValidateContextName before lookup to rule out typos/format errors."],"tags":["context","lookup","docker-engine","wrapper"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}