924060929 commented on code in PR #68811:
URL: https://github.com/apache/doris/pull/68811#discussion_r4246658720


##########
fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/client/JdbcDiagnosticException.java:
##########
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.connector.jdbc.client;
+
+import org.apache.doris.connector.spi.DiagnosticException;
+import org.apache.doris.connector.spi.DorisConnectorException;
+import org.apache.doris.jni.toolkit.jdbc.JdbcExceptionUtils;
+
+/** Connector-owned, sanitized JDBC diagnostics with the original driver cause 
retained. */
+public final class JdbcDiagnosticException extends DorisConnectorException 
implements DiagnosticException {
+    private final String[] sensitiveValues;
+
+    public JdbcDiagnosticException(String context, Throwable cause, String... 
sensitiveValues) {
+        super(JdbcExceptionUtils.format(context, cause, sensitiveValues), 
cause);

Review Comment:
   在当前 head `0acefb7` 复查后,这条还没有完整修复。`ExternalCatalog` / `CatalogIf` 
内部的几个日志点已经改了,但 `SHOW DATABASES FROM <jdbc_catalog>` 的最终语句执行出口仍会打印原始 cause:
   
   `ShowDatabasesCommand.doRun()` → `catalogIf.getDbNames()` → 
`PluginDrivenExternalCatalog.listDatabaseNames()` 记录脱敏后的 catalog 状态并继续抛异常 → 
`StmtExecutor` 第 957–963 行将整个异常传给 `LOG.info(..., e)`;随后第 773 行还会再次打印异常。
   
   `JdbcDiagnosticException` 只把自己的 message 脱敏,保留的原始 `SQLException` cause 
没变,所以只要驱动消息包含配置密码或 JDBC URL,日志展开 cause 时仍会输出原文。
   
   建议将“查找 DiagnosticException 策略并格式化完整外层异常”的逻辑放进 FE 公共异常诊断工具,由语句执行、job 和 
catalog 的最终输出点统一使用。连接器继续负责脱敏策略,FE 负责在输出边界应用策略。现在把公共逻辑挂在 `ExternalCatalog` 上、逐个补 
catalog catch,既让 `ConnectContextUtil` 依赖 catalog 实现,也容易漏掉其他消费者。
   
   请补一个经过 `SHOW DATABASES` 最终日志点的测试,检查日志展开后的完整 cause 链,而不只是检查异常 message:远端 
SQLSTATE/vendor code 应保留,配置密码和 URL 应消失。



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClientException.java:
##########
@@ -50,17 +72,6 @@ private static Object[] escapePercentInArgs(Object... args) {
     }
 
     public static String getAllExceptionMessages(Throwable throwable) {
-        StringBuilder sb = new StringBuilder();
-        while (throwable != null) {
-            String message = throwable.getMessage();
-            if (message != null && !message.isEmpty()) {
-                if (sb.length() > 0) {
-                    sb.append(" | Caused by: ");
-                }
-                sb.append(message);
-            }
-            throwable = throwable.getCause();
-        }
-        return sb.toString();
+        return JdbcExceptionUtils.format("", throwable);

Review Comment:
   当前 head `0acefb7` 中,消息重新聚合时已经传入 source password 和 JDBC 
URL,这部分已修复;不过最终日志仍存在同一个原始 cause 问题。
   
   `DataSourceConfigValidator.validateOceanBaseCompatibilityMode()` 第 184–190 
行构造的 `JobException` 消息已经脱敏,但仍把 `e` 保留为 cause。随后 
`StreamingInsertJob.initSourceJob()` 第 276 行执行 `log.warn("init streaming job 
for {} failed", dataSourceType, ex)`,会展开原始 `SQLException`。例如驱动消息为 `raw=<source 
password>` 时,外层 message 安全,日志中的 cause 仍包含密码。
   
   建议让这个最终日志出口也使用公共诊断格式化工具,并保留完整外层异常的脱敏策略;对于校验过程中直接抛出的 `SQLException`,也要带上 
source password/URL。测试应捕获 `StreamingInsertJob` 的实际日志,验证完整异常链,而不只验证 
`JobException.getMessage()`。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to