{"record":{"id":"8f4b05de6ca0a96d","repo":"geektutu/7days-golang","slug":"no-such-group-groupname","errorCode":null,"errorMessage":"no such group: \"+groupName","messagePattern":"no such group: \"\\+groupName","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"gee-cache/day3-http-server/geecache/http.go","lineNumber":50,"sourceCode":"// ServeHTTP handle all http requests\nfunc (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tif !strings.HasPrefix(r.URL.Path, p.basePath) {\n\t\tpanic(\"HTTPPool serving unexpected path: \" + r.URL.Path)\n\t}\n\tp.Log(\"%s %s\", r.Method, r.URL.Path)\n\t// /<basepath>/<groupname>/<key> required\n\tparts := strings.SplitN(r.URL.Path[len(p.basePath):], \"/\", 2)\n\tif len(parts) != 2 {\n\t\thttp.Error(w, \"bad request\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tgroupName := parts[0]\n\tkey := parts[1]\n\n\tgroup := GetGroup(groupName)\n\tif group == nil {\n\t\thttp.Error(w, \"no such group: \"+groupName, http.StatusNotFound)\n\t\treturn\n\t}\n\n\tview, err := group.Get(key)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/octet-stream\")\n\tw.Write(view.ByteSlice())\n}\n","sourceCodeStart":32,"sourceCodeEnd":63,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-cache/day3-http-server/geecache/http.go#L32-L63","documentation":"ServeHTTP parsed a valid /<group>/<key> path, but GetGroup(groupName) returned nil: no group with that name has been registered via NewGroup (or AddGroup). The pool responds 404 with body 'no such group: <name>'.","triggerScenarios":"GET /_geecache/<groupName>/<key> where groupName was never passed to geecache.NewGroup on THIS node, or the group was registered under a different name.","commonSituations":"Typo in the group name in the client URL; group created only in a different process/binary; multi-node deployment where one node registered the group and another didn't; renaming a group during refactoring without updating callers.","solutions":["Register the group on every node that serves it: g := geecache.NewGroup(name, cacheBytes, getter).","Verify the exact group name (case-sensitive) used in the URL matches NewGroup's name argument.","In multi-node setups, ensure all peers run the same group-registration bootstrap code.","List existing groups (log GetGroup results at startup) to confirm what names are actually registered."],"exampleFix":"// before: URL says 'users' but no group registered\nhttp.Get(\"http://localhost:8001/_geecache/users/42\")\n// after: register matching group first\ngeecache.NewGroup(\"users\", 2<<30, geecache.GetterFunc(func(key string) ([]byte, error) {\n    return loadUserFromDB(key)\n}))\nhttp.Get(\"http://localhost:8001/_geecache/users/42\")","handlingStrategy":"validation","validationCode":"// ensure the group exists locally before issuing HTTP cache reads\nfunc requireGroup(name string) error {\n    if geecache.GetGroup(name) == nil {\n        return fmt.Errorf(\"group %q not registered; call geecache.NewGroup first\", name)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Go: check the 404 status code\nresp, err := http.Get(url)\nif err == nil && resp.StatusCode == http.StatusNotFound {\n    return fmt.Errorf(\"unknown cache group in URL %q\", url)\n}","preventionTips":["Call geecache.NewGroup with the exact names used in URLs at every node's startup.","Centralize group-name constants shared by server registration and client URL building.","Treat 404 from the cache endpoint as a config error and fail fast with a clear log.","In clusters, run a startup self-check that GetGroup(name) != nil for all configured groups."],"tags":["http","cache","not-found","configuration"],"backgroundTag":"cache-group-not-found","analyzedSha":"cf3644382101dc13e7fd92e8f5c66cabc51bcd3b","analyzedAt":"2026-09-03T18:31:24.087Z","contentChangedAt":"2026-09-03T18:31:24.087Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}