geektutu/7days-golang · error
bad request
Error message
bad request
What it means
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 for the protobuf-based protocol. It fires on paths missing the key segment or with extra/missing slashes.
Source
Thrown at gee-cache/day7-proto-buf/geecache/http.go:54
basePath: defaultBasePath,
}
}
// Log info with server name
func (p *HTTPPool) Log(format string, v ...interface{}) {
log.Printf("[Server %s] %s", p.self, fmt.Sprintf(format, v...))
}
// ServeHTTP handle all http requests
func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.URL.Path, p.basePath) {
panic("HTTPPool serving unexpected path: " + r.URL.Path)
}
p.Log("%s %s", r.Method, r.URL.Path)
// /<basepath>/<groupname>/<key> required
parts := strings.SplitN(r.URL.Path[len(p.basePath):], "/", 2)
if len(parts) != 2 {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
groupName := parts[0]
key := parts[1]
group := GetGroup(groupName)
if group == nil {
http.Error(w, "no such group: "+groupName, http.StatusNotFound)
return
}
view, err := group.Get(key)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
View on GitHub (pinned to cf36443821)
Solutions
- Fix the requesting peer to build URLs as /<basepath>/<groupname>/<key>.
- Reject or log malformed requests instead of retrying them.
- Verify Set()/basePath configuration so path parsing lines up with how peers address this node.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at gee-cache/day7-proto-buf/geecache/http.go:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of geektutu/7days-golang@cf36443821 (2026-09-03).
Data as JSON: /api/errors/0da5f3655a49c2aa.
Report an issue: GitHub.