geektutu/7days-golang · error

no such group:

Error message

no such group: 

What it means

day5 ServeHTTP found no group registered under the requested name (GetGroup returned nil) and responds 404 'no such group: <name>'. Registration via NewGroup is per-process; multi-node deployments must register groups on every node.

Source

Thrown at gee-cache/day5-multi-nodes/geecache/http.go:60

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

// Set updates the pool's list of peers.
func (p *HTTPPool) Set(peers ...string) {
	p.mu.Lock()
	defer p.mu.Unlock()
	p.peers = consistenthash.New(defaultReplicas, nil)

View on GitHub (pinned to cf36443821)

Solutions

  1. Register the group with geecache.NewGroup on every node before serving traffic.
  2. Cross-check the requested group name (exact, case-sensitive) with NewGroup arguments.
  3. Drive group registration from shared config so all peers stay in sync.
  4. Add a startup assertion/log that lists all registered groups per node.

Example fix

// before: only node A registers the group
// node B: no NewGroup -> 404 from B
// after: identical bootstrap on all nodes
for _, cfg := range groupConfigs {
    geecache.NewGroup(cfg.Name, cfg.Bytes, geecache.GetterFunc(cfg.Loader))
}
Defensive patterns

Strategy: validation

Validate before calling

// day5 multi-node: assert all configured groups exist on this node at startup
for _, name := range config.GroupNames {
    if geecache.GetGroup(name) == nil {
        log.Fatalf("group %q not registered on this node", name)
    }
}

Try / catch

// Go: surface 404 as a config error
if resp.StatusCode == http.StatusNotFound {
    return fmt.Errorf("group missing on peer %s: %s", addr, body)
}

Prevention

When it happens

Trigger: GET with a group name absent from this node's registry; name typo; peer started without the group-registration bootstrap.

Common situations: Rolling out new nodes with stale config; inconsistent NewGroup calls across the cluster; renaming groups without updating all client URLs.

Related errors


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