Below is a fragment of a PR for a small HTTP service in Go 1.24 (standard library only). The service accepts POST /delivery-notes with JSON of the form {"request_id":"...","order_id":"..."} and stores a record in memory.
Functional requirements:
r.Body.r.Context() is already canceled before saving starts or is canceled while waiting, the handler must not save the record and must respond with 499 Client Closed Request.request_id returns 202 Accepted only after the record is guaranteed to have been added to the storage.request_id must not create a second record and must return the same public result: 202 Accepted.Store is used by multiple requests at the same time, so access to shared state must be synchronized. There are no additional goroutines in this task.Run environment:
go test ./... or start an http.Server with this handlerYou need to review the after-version: find defects in the change, explain the consequences, and suggest a correct fix.
Go 1.24, standard library. Concurrent HTTP request handling by a single process is assumed. User status 499 is written via w.WriteHeader(499) without additional libraries.
Use line comments to explain the problem, its impact, the fix and how to test it.