Code RoomNew required field breaks clients
HardPrep Room Coding #1995

New required field breaks clients

Code reviewCode quality & reviewSenior–Staff~25 min

Review this Go change that adds a new field to a create-request struct for an existing v1 endpoint.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1type CreateInvoiceReq struct {
2 CustomerID string `json:"customer_id"`
3 Amount int64 `json:"amount"`
4 Currency string `json:"currency"`
5}
6 
7func createInvoice(w http.ResponseWriter, r *http.Request) {
8 var req CreateInvoiceReq
9 json.NewDecoder(r.Body).Decode(&req)
10 if req.Currency == "" {
11 http.Error(w, "currency is required", 400) // newly added check
12 }
13 inv := invoices.Create(req.CustomerID, req.Amount, req.Currency)
14 writeJSON(w, 201, inv)
15}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.