This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git

commit ef8c1ebb8862d573915a699ab1a98c690549be96
Author: LinkinStars <[email protected]>
AuthorDate: Fri Jun 13 16:01:05 2025 +0800

    fix(notification): handle potential nil pointer dereference #1356
---
 internal/service/notification_common/notification.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/internal/service/notification_common/notification.go 
b/internal/service/notification_common/notification.go
index 5edb6652..2bceb629 100644
--- a/internal/service/notification_common/notification.go
+++ b/internal/service/notification_common/notification.go
@@ -132,6 +132,7 @@ func (ns *NotificationCommon) AddNotification(ctx 
context.Context, msg *schema.N
                objInfo, err = ns.objectInfoService.GetInfo(ctx, 
req.ObjectInfo.ObjectID)
                if err != nil {
                        log.Error(err)
+                       return err
                } else {
                        req.ObjectInfo.Title = objInfo.Title
                        questionID = objInfo.QuestionID
@@ -354,6 +355,9 @@ func (ns *NotificationCommon) 
SendNotificationToAllFollower(ctx context.Context,
 
 func (ns *NotificationCommon) syncNotificationToPlugin(ctx context.Context, 
objInfo *schema.SimpleObjectInfo,
        msg *schema.NotificationMsg) {
+       if objInfo == nil {
+               return
+       }
        siteInfo, err := ns.siteInfoService.GetSiteGeneral(ctx)
        if err != nil {
                log.Errorf("get site general info failed: %v", err)

Reply via email to