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

jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 2624cc01fec Fix error message when altering a non-exist user (#16126)
2624cc01fec is described below

commit 2624cc01fec90ec3efe6472774ae0b84b6f3f48e
Author: Jiang Tian <[email protected]>
AuthorDate: Fri Aug 8 14:32:56 2025 +0800

    Fix error message when altering a non-exist user (#16126)
---
 .../org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java | 14 ++++++++++++++
 .../org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java  |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
index 249368ac914..f2f0aef18ba 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBRelationalAuthIT.java
@@ -44,6 +44,8 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 @RunWith(IoTDBTestRunner.class)
 @Category({TableLocalStandaloneIT.class, TableClusterIT.class})
 public class IoTDBRelationalAuthIT {
@@ -620,4 +622,16 @@ public class IoTDBRelationalAuthIT {
       Assert.fail();
     }
   }
+
+  @Test
+  public void testAlterNonExistingUser() throws SQLException {
+    try (Connection adminCon = 
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        Statement adminStmt = adminCon.createStatement()) {
+      try {
+        adminStmt.execute("ALTER USER nonExist SET PASSWORD 'asdfer1124566'");
+      } catch (SQLException e) {
+        assertEquals("701: User nonExist not found", e.getMessage());
+      }
+    }
+  }
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
index 4dbad54d51c..863a3653263 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
@@ -540,10 +540,10 @@ public class ClusterAuthorityFetcher implements 
IAuthorityFetcher {
       } catch (ClientManagerException | TException e) {
         LOGGER.error(CONNECTERROR);
       }
-      user = cacheUser(permissionInfoResp);
       if (permissionInfoResp != null
           && permissionInfoResp.getStatus().getCode()
               == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+        user = cacheUser(permissionInfoResp);
         if (acceptCache) {
           iAuthorCache.putUserCache(userName, user);
         }

Reply via email to