{"record":{"id":"208342420bf2235f","repo":"geektutu/7days-golang","slug":"bad-request-208342","errorCode":null,"errorMessage":"bad request","messagePattern":"bad request","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"gee-cache/day6-single-flight/geecache/http.go","lineNumber":51,"sourceCode":"\t\tbasePath: defaultBasePath,\n\t}\n}\n\n// Log info with server name\nfunc (p *HTTPPool) Log(format string, v ...interface{}) {\n\tlog.Printf(\"[Server %s] %s\", p.self, fmt.Sprintf(format, v...))\n}\n\n// 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","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-cache/day6-single-flight/geecache/http.go#L33-L69","documentation":"HTTP 400 response in HTTPPool.ServeHTTP: the URL path after basePath does not split into exactly two parts \"<groupname>/<key>\", so the peer request is malformed. It fires on paths missing the key segment or with unexpected slash structure.","triggerScenarios":"Thrown at gee-cache/day6-single-flight/geecache/http.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return a 400 status with a clear message instructing the client to use the URL format /<basePath>/<groupname>/<key>","Log the received path server-side to aid debugging of malformed requests","Add client-side URL construction helpers so callers build valid cache paths instead of hand-crafting them"],"exampleFix":null,"handlingStrategy":"validation","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"}