|
|
@@ -193,15 +193,13 @@ func (s *Server) processAlert(ctx context.Context, alert *pbv1.Alert, src *pipel
|
|
|
}
|
|
|
|
|
|
// Override the Sources map for this call to use the authenticated source.
|
|
|
- // This ensures company_id/source_id from the API key match the alert body.
|
|
|
+ // Per-call Sources map — passed in, never mutates s.Dep.Sources. Avoids
|
|
|
+ // concurrent map read/write between gRPC goroutines sharing Deps.
|
|
|
sourceKey := src.CompanyID + ":" + src.SourceID
|
|
|
- origSources := s.Dep.Sources
|
|
|
- s.Dep.Sources = map[string]pipeline.SourceConfig{sourceKey: *src}
|
|
|
+ callDeps := s.Dep // value copy; underlying pointers/maps are shared safely
|
|
|
+ callDeps.Sources = map[string]pipeline.SourceConfig{sourceKey: *src}
|
|
|
|
|
|
- res := s.Dep.Process(ctx, body, "" /* no HMAC for gRPC */)
|
|
|
-
|
|
|
- // Restore the original Sources map.
|
|
|
- s.Dep.Sources = origSources
|
|
|
+ res := callDeps.Process(ctx, body, "" /* no HMAC for gRPC */)
|
|
|
|
|
|
if !res.Accepted {
|
|
|
code := errorCode(res.RejectReason)
|