{"record":{"id":"1319067557f70011","repo":"docker/cli","slug":"failed-to-remove-context-s-w","errorCode":null,"errorMessage":"failed to remove context %s: %w","messagePattern":"failed to remove context (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/context/store/store.go","lineNumber":144,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnames := make([]string, 0, len(list))\n\tfor _, item := range list {\n\t\tnames = append(names, item.Name)\n\t}\n\treturn names, nil\n}\n\n// CreateOrUpdate creates or updates metadata for the context.\nfunc (s *ContextStore) CreateOrUpdate(meta Metadata) error {\n\treturn s.meta.createOrUpdate(meta)\n}\n\n// Remove deletes the context with the given name, if found.\nfunc (s *ContextStore) Remove(name string) error {\n\tif err := s.meta.remove(name); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove context %s: %w\", name, err)\n\t}\n\tif err := s.tls.remove(name); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove context %s: %w\", name, err)\n\t}\n\treturn nil\n}\n\n// GetMetadata returns the metadata for the context with the given name.\n// It returns an errdefs.ErrNotFound if the context was not found.\nfunc (s *ContextStore) GetMetadata(name string) (Metadata, error) {\n\treturn s.meta.get(name)\n}\n\n// ResetTLSMaterial removes TLS data for all endpoints in the context and replaces\n// it with the new data.\nfunc (s *ContextStore) ResetTLSMaterial(name string, data *ContextTLSData) error {\n\tif err := s.tls.remove(name); err != nil {\n\t\treturn err","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/context/store/store.go#L126-L162","documentation":"Returned by ContextStore.Remove when removing the context's metadata fails; wraps the meta.remove error (which itself is 508). This is the first of two removal steps — if it fails, TLS removal (511) is not attempted.","triggerScenarios":"Calling store.Remove(name) when the metadata directory cannot be deleted (permissions, read-only FS, locked files).","commonSituations":"Ownership mismatch between files and the running user; read-only filesystem; files locked by another process.","solutions":["Fix ownership/permissions on ~/.docker/contexts/meta/<hash>.","Remove the metadata directory manually as the appropriate user.","Verify the filesystem is writable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := store.Remove(name); err != nil {\n    if errors.Is(err, os.ErrPermission) {\n        // chown the meta dir, or rm -rf ~/.docker/contexts/meta/<hash> as the owner\n    }\n    return err\n}","preventionTips":["Manage contexts as the owning user to avoid permission denials on removal.","Keep ~/.docker owned by a single user, not mixed root/user.","Check the filesystem isn't read-only before bulk cleanup."],"tags":["context","cleanup","permissions","filesystem"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}