geektutu/7days-golang · error

no such group: "+groupName

Error message

no such group: "+groupName

What it means

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>'.

Source

Thrown at gee-cache/day3-http-server/geecache/http.go:50

// 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
	}

	w.Header().Set("Content-Type", "application/octet-stream")
	w.Write(view.ByteSlice())
}

View on GitHub (pinned to cf36443821)

Solutions

  1. Register the group on every node that serves it: g := geecache.NewGroup(name, cacheBytes, getter).
  2. Verify the exact group name (case-sensitive) used in the URL matches NewGroup's name argument.
  3. In multi-node setups, ensure all peers run the same group-registration bootstrap code.
  4. List existing groups (log GetGroup results at startup) to confirm what names are actually registered.

Example fix

// before: URL says 'users' but no group registered
http.Get("http://localhost:8001/_geecache/users/42")
// after: register matching group first
geecache.NewGroup("users", 2<<30, geecache.GetterFunc(func(key string) ([]byte, error) {
    return loadUserFromDB(key)
}))
http.Get("http://localhost:8001/_geecache/users/42")
Defensive patterns

Strategy: validation

Validate before calling

// ensure the group exists locally before issuing HTTP cache reads
func requireGroup(name string) error {
    if geecache.GetGroup(name) == nil {
        return fmt.Errorf("group %q not registered; call geecache.NewGroup first", name)
    }
    return nil
}

Try / catch

// Go: check the 404 status code
resp, err := http.Get(url)
if err == nil && resp.StatusCode == http.StatusNotFound {
    return fmt.Errorf("unknown cache group in URL %q", url)
}

Prevention

When it happens

Trigger: GET /_geecache/<groupName>/<key> where groupName was never passed to geecache.NewGroup on THIS node, or the group was registered under a different name.

Common situations: 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.

Related errors


AI-assisted analysis of geektutu/7days-golang@cf36443821 (2026-09-03). Data as JSON: /api/errors/8f4b05de6ca0a96d. Report an issue: GitHub.