Code Room
Vibe codingHardvc-g136
Subject Ai code reviewLevel Senior–Staff~20 minCommon in Concurrency interviewsIndustries Software development

Question

An agent wrote this Go cache-with-TTL for a hot path and it passed your unit tests. It looks idiomatic, but it's wrong under concurrency in a way your tests didn't catch. Find the bug, explain the input/timing that triggers it, give the fix, and say what about reviewing AI code makes this class of bug easy to miss.

go
type Cache struct {    mu    sync.RWMutex    items map[string]item}type item struct { val string; exp time.Time } func (c *Cache) Get(k string) (string, bool) {    c.mu.RLock()    it, ok := c.items[k]    c.mu.RUnlock()    if !ok || time.Now().After(it.exp) {        c.mu.RLock()        delete(c.items, k)   // evict expired        c.mu.RUnlock()        return "", false    }    return it.val, true}
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.