geektutu/7days-golang · error

err.Error()

Error message

err.Error()

What it means

Generic 500 handler in HTTPPool.ServeHTTP: group.Get(key) failed (getter error, peer fetch failure), and the raw error text is written as the response body before protobuf marshaling is reached. It fires for any cache-retrieval error during a peer HTTP request.

Source

Thrown at gee-cache/day7-proto-buf/geecache/http.go:69

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

	// Write the value to the response body as a proto message.
	body, err := proto.Marshal(&pb.Response{Value: view.ByteSlice()})
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

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

// Set updates the pool's list of peers.
func (p *HTTPPool) Set(peers ...string) {
	p.mu.Lock()
	defer p.mu.Unlock()

View on GitHub (pinned to cf36443821)

Solutions

  1. Log the full error server-side to find the root cause (getter error, peer network failure).
  2. Retry the request; transient peer failures typically resolve on a second attempt.
  3. Map known errors (e.g. key not found) to more precise status codes than 500.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at gee-cache/day7-proto-buf/geecache/http.go:69 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/b91029624dbee022. Report an issue: GitHub.