{"record":{"id":"c9651554f982659b","repo":"geektutu/7days-golang","slug":"err-error-c96515","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"gee-cache/day6-single-flight/geecache/http.go","lineNumber":66,"sourceCode":"\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\n// Set updates the pool's list of peers.\nfunc (p *HTTPPool) Set(peers ...string) {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\tp.peers = consistenthash.New(defaultReplicas, nil)\n\tp.peers.Add(peers...)\n\tp.httpGetters = make(map[string]*httpGetter, len(peers))\n\tfor _, peer := range peers {\n\t\tp.httpGetters[peer] = &httpGetter{baseURL: peer + p.basePath}\n\t}\n}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-cache/day6-single-flight/geecache/http.go#L48-L84","documentation":"Generic 500 handler in HTTPPool.ServeHTTP: group.Get(key) failed (getter error, peer fetch failure, single-flight error), and the raw error text is written as the response body. It fires for any cache-retrieval error during a peer HTTP request.","triggerScenarios":"Thrown at gee-cache/day6-single-flight/geecache/http.go:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the full error server-side to find the root cause (getter panic, network to peers, timeout).","Retry the request; transient peer failures under single-flight usually resolve on a second attempt.","Map known errors (e.g. key not found) to more precise status codes than 500."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}