{"record":{"id":"3225a3b876a1b87a","repo":"docker/cli","slug":"endpoint-q-is-not-of-type-endpointmeta","errorCode":null,"errorMessage":"endpoint %q is not of type EndpointMeta","messagePattern":"endpoint %q is not of type EndpointMeta","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/docker/load.go","lineNumber":160,"sourceCode":"// named pipe (Windows), or file-descriptor.\nfunc isSocket(addr string) bool {\n\tswitch proto, _, _ := strings.Cut(addr, \"://\"); proto {\n\tcase \"unix\", \"npipe\", \"fd\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// EndpointFromContext parses a context docker endpoint metadata into a typed EndpointMeta structure\nfunc EndpointFromContext(metadata store.Metadata) (EndpointMeta, error) {\n\tep, ok := metadata.Endpoints[DockerEndpoint]\n\tif !ok {\n\t\treturn EndpointMeta{}, errors.New(\"cannot find docker endpoint in context\")\n\t}\n\ttyped, ok := ep.(EndpointMeta)\n\tif !ok {\n\t\treturn EndpointMeta{}, fmt.Errorf(\"endpoint %q is not of type EndpointMeta\", DockerEndpoint)\n\t}\n\treturn typed, nil\n}\n","sourceCodeStart":142,"sourceCodeEnd":164,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/docker/load.go#L142-L164","documentation":"Returned by docker.EndpointFromContext() when the stored endpoint metadata under the \"docker\" key cannot be type-asserted to docker.EndpointMeta (= context.EndpointMetaBase). The value is present but shaped as a generic map[string]any or a different struct, not the expected typed endpoint.","triggerScenarios":"Calling EndpointFromContext(meta) after store.GetMetadata on a context whose \"docker\" endpoint value is a map[string]any rather than the EndpointMeta struct. This occurs when the store's Config did not register a TypeGetter for the \"docker\" endpoint, or the context was written by a tool/CLI version with a different endpoint schema.","commonSituations":"Reading a context created by an older/newer docker CLI with endpoint schema drift; using a store constructed without the docker endpoint TypeGetter; importing a context archive produced by another tool; plugin-provided endpoints read by a CLI lacking that plugin.","solutions":["Recreate the context with the current CLI: `docker context create` (or import from an archive produced by a compatible version).","Ensure the store was built with the docker context Config that registers the \"docker\" endpoint TypeGetter.","If you only need Host/SkipTLSVerify, fall back to reading the endpoint as a generic map[string]any instead of asserting EndpointMeta."],"exampleFix":"// before\nep, err := docker.EndpointFromContext(meta) // panics-free, but errors on schema drift\n\n// after: type-guard the endpoint value\nraw := meta.Endpoints[docker.DockerEndpoint]\nif m, ok := raw.(docker.EndpointMeta); ok {\n    // use m\n} else if mm, ok := raw.(map[string]any); ok {\n    // tolerant fallback: read mm[\"Host\"] etc.\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// isEndpointMeta narrows a stored endpoint value to docker.EndpointMeta.\nfunc isEndpointMeta(v any) (docker.EndpointMeta, bool) {\n    // fast path: already typed\n    if m, ok := v.(docker.EndpointMeta); ok {\n        return m, true\n    }\n    // tolerant path: untyped map from a store without the TypeGetter\n    if mm, ok := v.(map[string]any); ok {\n        host, _ := mm[\"Host\"].(string)\n        skip, _ := mm[\"SkipTLSVerify\"].(bool)\n        return docker.EndpointMeta{EndpointMetaBase: context.EndpointMetaBase{Host: host, SkipTLSVerify: skip}}, true\n    }\n    return docker.EndpointMeta{}, false\n}","tryCatchPattern":null,"preventionTips":["Construct the store with the docker context Config so the 'docker' endpoint gets a TypeGetter.","Recreate/import contexts with the CLI version that will read them to avoid schema drift.","Tolerate map[string]any as a fallback when reading foreign contexts."],"tags":["context","type-assertion","schema","docker-engine","endpoints"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}