{"record":{"id":"f22fafdccb85a92c","repo":"docker/cli","slug":"failed-to-retrieve-tls-files-for-context-q-w","errorCode":null,"errorMessage":"failed to retrieve TLS files for context %q: %w","messagePattern":"failed to retrieve TLS files for context %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/tlsdata.go","lineNumber":48,"sourceCode":"\t\tFiles: make(map[string][]byte),\n\t}\n\tif data.CA != nil {\n\t\tresult.Files[caKey] = data.CA\n\t}\n\tif data.Cert != nil {\n\t\tresult.Files[certKey] = data.Cert\n\t}\n\tif data.Key != nil {\n\t\tresult.Files[keyKey] = data.Key\n\t}\n\treturn &result\n}\n\n// LoadTLSData loads TLS data from the store\nfunc LoadTLSData(s store.Reader, contextName, endpointName string) (*TLSData, error) {\n\ttlsFiles, err := s.ListTLSFiles(contextName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to retrieve TLS files for context %q: %w\", contextName, err)\n\t}\n\tif epTLSFiles, ok := tlsFiles[endpointName]; ok {\n\t\tvar tlsData TLSData\n\t\tfor _, f := range epTLSFiles {\n\t\t\tdata, err := s.GetTLSData(contextName, endpointName, f)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to retrieve TLS data (%s) for context %q: %w\", f, contextName, err)\n\t\t\t}\n\t\t\tswitch f {\n\t\t\tcase caKey:\n\t\t\t\ttlsData.CA = data\n\t\t\tcase certKey:\n\t\t\t\ttlsData.Cert = data\n\t\t\tcase keyKey:\n\t\t\t\ttlsData.Key = data\n\t\t\tdefault:\n\t\t\t\tlogrus.Warnf(\"unknown file in context %s TLS bundle: %s\", contextName, f)\n\t\t\t}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/tlsdata.go#L30-L66","documentation":"Returned by LoadTLSData in cli/context/tlsdata.go when store.Reader.ListTLSFiles fails for the named context. It is the higher-level wrapper around the lower-level store error (e.g. error 520), annotating which context the TLS bundle load was attempted for so the user can target the right context store entry.","triggerScenarios":"Calling context.LoadTLSData(s, contextName, endpointName) where s.ListTLSFiles(contextName) errors. This happens when the context's TLS directory cannot be read at all (tlsstore.go listContextData returns a wrapped os.ReadDir error), i.e. permission denied or I/O failure on the top-level context TLS dir.","commonSituations":"Migrating ~/.docker between machines/owners, a partially-cloned docker config, docker running under a different UID than the one that created the context, or a corrupt context store after a crash during context create/import.","solutions":["Check `docker context ls` and `docker context inspect <name>` to confirm the context exists and points at a valid Docker endpoint.","Fix ownership/permissions of ~/.docker/contexts recursively: `sudo chown -R $USER ~/.docker`.","Recreate the context with `docker context rm <name>` and `docker context create`.","Re-import the context from a known-good file with `docker context import <name> <file>`."],"exampleFix":"// before\ntls, err := context.LoadTLSData(s, name, endpoint)\n\n// after: verify the context resolves in the store first\nif _, err := s.GetMetadata(name); err != nil {\n    return fmt.Errorf(\"context %q unavailable, will not load TLS: %w\", name, err)\n}","handlingStrategy":"validation","validationCode":"// Confirm the context exists and its metadata dir is accessible before loading TLS\nif _, err := s.GetMetadata(contextName); err != nil {\n    return fmt.Errorf(\"context %q not resolvable; skip TLS load: %w\", contextName, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate contexts with `docker context inspect` before trusted operations.","Fix ~/.docker ownership after any UID change.","Recreate contexts from a known-good export rather than copying files manually."],"tags":["filesystem","tls","docker-context","config"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}