Code RoomGET endpoint modifies database state
MediumPrep Room Coding #1986

GET endpoint modifies database state

Code reviewNetworking & APIsMid–Senior~20 min

Review this Go HTTP handler exposed at `GET /reports/:id/export`.

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 20 min
Mark a line and say what kind of problem it is.0 findings
1func exportReport(w http.ResponseWriter, r *http.Request) {
2 id := chi.URLParam(r, "id")
3 report := repo.Get(id)
4 file := renderPDF(report) // heavy, ~3s
5 repo.IncrementExportCount(id) // writes to DB
6 audit.Log("export", id) // side effect
7 w.Header().Set("Content-Type", "application/pdf")
8 w.Write(file)
9}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.