From 700963994b673627a51275ed3f98b8a421229401 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Wed, 11 Feb 2026 16:04:14 +0800 Subject: [PATCH] fix: remove invalid DBus error message sending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Removed code that created and sent QDBusError messages directly via QDBusConnection::sessionBus().send() 2. Replaced with proper logging using qWarning() when notification creation fails 3. This fixes a protocol violation where error messages were being sent without proper reply serial numbers 4. The original implementation was creating standalone error messages which is not allowed by DBus specification 5. Now only logs the failure internally without attempting to send invalid DBus messages Influence: 1. Test notification creation with invalid parameters to ensure proper error handling 2. Verify that no invalid DBus messages are sent when notifications fail 3. Check system logs for warning messages when notification creation fails 4. Ensure notification service continues to function normally after failed requests 5. Test with various DBus clients to confirm protocol compliance fix: 移除无效的 DBus 错误消息发送 1. 删除了通过 QDBusConnection::sessionBus().send() 直接创建和发送 QDBusError 消息的代码 2. 替换为使用 qWarning() 进行适当日志记录,当通知创建失败时 3. 修复了协议违规问题,错误消息在没有正确回复序列号的情况下被发送 4. 原始实现创建了独立的错误消息,这违反了 DBus 规范 5. 现在仅在内部记录失败日志,而不尝试发送无效的 DBus 消息 Influence: 1. 测试使用无效参数创建通知,确保正确的错误处理 2. 验证当通知失败时不会发送无效的 DBus 消息 3. 检查系统日志中通知创建失败时的警告消息 4. 确保通知服务在请求失败后继续正常运行 5. 使用各种 DBus 客户端测试以确认协议合规性 PMS: BUG-350869 --- panels/notification/server/dbusadaptor.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/panels/notification/server/dbusadaptor.cpp b/panels/notification/server/dbusadaptor.cpp index 61438fdab..d1fe495a4 100644 --- a/panels/notification/server/dbusadaptor.cpp +++ b/panels/notification/server/dbusadaptor.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -32,10 +32,7 @@ uint DbusAdaptor::Notify(const QString &appName, uint replacesId, const QString { uint id = manager()->Notify(appName, replacesId, appIcon, summary, body, actions, hints, expireTimeout); if (id == 0) { - QDBusError error(QDBusError::InternalError, "Notify failed."); - QDBusMessage reply = QDBusMessage::createError(error); - - QDBusConnection::sessionBus().send(reply); + qWarning(notifyLog) << "Notify failed for app:" << appName; } return id; @@ -76,10 +73,7 @@ uint DDENotificationDbusAdaptor::Notify(const QString &appName, uint replacesId, { uint id = manager()->Notify(appName, replacesId, appIcon, summary, body, actions, hints, expireTimeout); if (id == 0) { - QDBusError error(QDBusError::InternalError, "Notify failed."); - QDBusMessage reply = QDBusMessage::createError(error); - - QDBusConnection::sessionBus().send(reply); + qWarning(notifyLog) << "Notify failed for app:" << appName; } return id;