diff --git a/server/datastore/mysql/apple_mdm_batched.go b/server/datastore/mysql/apple_mdm_batched.go index 90bb0b09c1..31a78a5f13 100644 --- a/server/datastore/mysql/apple_mdm_batched.go +++ b/server/datastore/mysql/apple_mdm_batched.go @@ -280,6 +280,10 @@ func (ds *Datastore) listAppleProfilesForReconcileTransaction(ctx context.Contex for uuid, ia := range includeModes { p := byUUID[uuid] + if p == nil { + // Should not happen, so not worth logging anything here. + continue + } if ia.mixed { // Defensive: include rows disagreed on require_all (should // be impossible in production — the upsert path enforces a @@ -287,7 +291,9 @@ func (ds *Datastore) listAppleProfilesForReconcileTransaction(ctx context.Contex // intent; exclude labels (if any) are preserved. p.IncludeLabels = nil p.IncludeMode = fleet.AppleProfileIncludeNone - ds.logger.WarnContext(ctx, "apple profile has mixed include label modes; ignoring include labels", "profile_uuid", uuid, "team_id", p.TeamID) + errMsg := "apple profile has mixed include label modes; ignoring include labels" + ds.logger.ErrorContext(ctx, errMsg, "profile_uuid", uuid, "team_id", p.TeamID) + ctxerr.Handle(ctx, ctxerr.New(ctx, errMsg)) continue } p.IncludeMode = ia.mode @@ -581,11 +587,17 @@ func (ds *Datastore) listAppleDeclarationsForReconcileTransaction(ctx context.Co for uuid, ia := range includeModes { d := byUUID[uuid] + if d == nil { + // Should never happen, so not worth logging anything here. + continue + } if ia.mixed { d.IncludeLabels = nil d.IncludeMode = fleet.AppleProfileIncludeNone - ds.logger.WarnContext(ctx, "apple declaration has mixed include label modes; ignoring include labels", "declaration_uuid", uuid, "team_id", d.TeamID) + errMsg := "apple declaration has mixed include label modes; ignoring include labels" + ds.logger.ErrorContext(ctx, errMsg, "declaration_uuid", uuid, "team_id", d.TeamID) + ctxerr.Handle(ctx, ctxerr.New(ctx, errMsg)) continue } d.IncludeMode = ia.mode