Code Room
Vibe codingHardvc-g102
Subject Ai code reviewLevel Senior–Staff~18 minCommon in Networking & APIs interviewsIndustries Software development

Question

An AI assistant wrote this Go client wrapper to make a POST to a payment provider resilient by retrying on failure. It passed integration tests against a mock that never timed out. In production, a small number of customers were charged twice.

go
func postWithRetry(url string, body []byte) (*http.Response, error) {    var resp *http.Response    var err error    for i := 0; i < 3; i++ {        resp, err = http.Post(url, "application/json", bytes.NewReader(body))        if err == nil && resp.StatusCode < 500 {            return resp, nil        }        time.Sleep(time.Second)    }    return resp, err}

Why did some customers get double-charged, and how do you make retries safe?

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.