{"id":"a4bd0f3c155a780c","repo":"docker/cli","slug":"no-context-store-initialized","errorCode":null,"errorMessage":"no context store initialized","messagePattern":"no context store initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/cli.go","lineNumber":324,"sourceCode":"\t\treturn nil, err\n\t}\n\tif len(configFile.HTTPHeaders) > 0 {\n\t\topts = append(opts, client.WithHTTPHeaders(configFile.HTTPHeaders))\n\t}\n\twithCustomHeaders, err := withCustomHeadersFromEnv()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif withCustomHeaders != nil {\n\t\topts = append(opts, withCustomHeaders)\n\t}\n\topts = append(opts, extraOpts...)\n\treturn client.New(opts...)\n}\n\nfunc resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {\n\tif s == nil {\n\t\treturn docker.Endpoint{}, errors.New(\"no context store initialized\")\n\t}\n\tctxMeta, err := s.GetMetadata(contextName)\n\tif err != nil {\n\t\treturn docker.Endpoint{}, err\n\t}\n\tepMeta, err := docker.EndpointFromContext(ctxMeta)\n\tif err != nil {\n\t\treturn docker.Endpoint{}, err\n\t}\n\treturn docker.WithTLSData(s, contextName, epMeta)\n}\n\n// Resolve the Docker endpoint for the default context (based on config, env vars and CLI flags)\nfunc resolveDefaultDockerEndpoint(opts *cliflags.ClientOptions) (docker.Endpoint, error) {\n\t// defaultToTLS determines whether we should use a TLS host as default\n\t// if nothing was configured by the user.\n\tdefaultToTLS := opts.TLSOptions != nil\n\thost, err := getServerHost(opts.Hosts, defaultToTLS)","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/cli.go#L306-L342","documentation":"resolveDockerEndpoint looks up the daemon endpoint (host URL, TLS material) for a named context from a context store.Reader. If the store passed in is nil there is nowhere to read context metadata from, so it fails fast with this error instead of dereferencing nil. In the stock CLI a store is always constructed; a nil store indicates DockerCli was used before Initialize, or embedding code skipped store setup.","triggerScenarios":"Calling code paths that reach resolveDockerEndpoint (e.g. resolving a context's endpoint for client creation) with a nil store.Reader — typically a DockerCli constructed manually without NewDockerCli/Initialize, or a unit test invoking endpoint resolution before wiring a context store.","commonSituations":"Third-party Go programs embedding docker/cli's command package and calling client-resolution helpers before cli.Initialize(); custom builds where contextStore initialization was refactored out; test code constructing DockerCli structs directly.","solutions":["Call DockerCli.Initialize(opts) (or construct via command.NewDockerCli) before any operation that resolves contexts or creates API clients","In embedding code, build a store explicitly: store.New(config.ContextStoreDir(), command.DefaultContextStoreConfig()) and pass it to endpoint resolution","In tests, inject a ContextStoreWithDefault or a fake store.Reader instead of nil"],"exampleFix":"// before\ncli := &command.DockerCli{}\nep, err := resolveDockerEndpoint(nil, \"default\")\n// after\ncli, _ := command.NewDockerCli()\n_ = cli.Initialize(cliflags.NewClientOptions())\n// endpoint resolution now uses cli's initialized context store","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","context-store","initialization","embedding","nil-check"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}