Below is a fragment of a PR with changes in the HTTP handler for synchronizing a journal entry. The handler accepts JSON, sends the data to an external service, and stores the result in an in-memory journal by request key.
You need to review the changes and find behavioral defects. Assume that the handler is used concurrently from multiple goroutines, and a repeated request with the same Idempotency-Key must return the previously saved result without repeating the external call.
POST /sync accepts JSON of the form {"entry_id":"e-1","payload":"text"}.Idempotency-Key header is required and must identify exactly one successful result.Client.Push with the same context.Context that came in the HTTP request;Store;201 Created and the result body.Client.Push.Store.Store state must be safe under concurrent requests.before and after.Idempotency-Key;context.Context;Idempotency-Key under concurrency, there must be only one external call and one stored result entry.Store.1.24net/httpStore is shared between concurrent requests from different goroutinesClient.Push(ctx, req) must respect ctx cancellationUse line comments to explain the problem, its impact, the fix and how to test it.