Chat2DB
Chat2DB copied to clipboard
ssh方式连接PostgreSQL,报错host must not be null
Chat2DB Version
1.0.11
Describe the bug
Chat2DB版本:1.0.11
系统版本:macOS Ventura 13.4.1
缺陷描述:
场景:通过 ssh 连接 PostgreSQL 数据库
前提:常规选项卡已填写主机、端口、用户名、密码、数据库,SSH选项卡选择使用SSH为true,并已填写主机、端口、用户名、密码
-
点击常规选项卡-【测试连接】,报错“host must not be null.: null”;
-
点击SSH选项卡-【测试SSH连接】,报错“COMMON_SYSTEM_ERROR: 系统开小差啦,请尝试刷新页面或者联系管理员 ”
后台日志打印参数中,ssh部分缺少host参数,如下图
POST http://127.0.0.1:10824/api/connection/ssh/pre_connect Accept: application/json Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN Connection: keep-alive Content-Length: 101 Content-Type: application/json Host: 127.0.0.1:10824 sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="104" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "macOS" Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) chat2db/1.0.11 Chrome/104.0.5112.114 Electron/20.1.4 Safari/537.36
{"use":"true","host":"127.0.0.1","port":"22","userName":"kane","localPort":"","password":"testPassword"} response: {"success":false,"errorCode":"COMMON_SYSTEM_ERROR","errorMessage":"系统开小差啦,请尝试刷新页面或者联系管理员","traceId":null}
POST http://127.0.0.1:10824/api/connection/datasource/pre_connect Accept: application/json Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN Connection: keep-alive Content-Length: 359 Content-Type: application/json Host: 127.0.0.1:10824 sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="104" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "macOS" Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) chat2db/1.0.11 Chrome/104.0.5112.114 Electron/20.1.4 Safari/537.36
{"ssh":{"use":"true","host":"127.0.0.1","port":"22","userName":"kane","localPort":"","password":"testPassword"},"alias":"@localhost","host":"192.168.31.21","port":"5432","authentication":1,"user":"postgres","password":"postgres","database":"postgres","url":"jdbc:postgresql://192.168.31.21:5432/postgres","extendInfo":[],"EnvType":"DAILY","type":"POSTGRESQL"}
response: {"success":false,"errorCode":"host must not be null.","errorMessage":null,"traceId":null}
问题分析
-
测试连接、测试ssh连接报错host不能为空问题 chat2db-server/chat2db-spi/src/main/java/ai/chat2db/spi/model/SSHInfo.java 该文件定义ssh主机名为hostName,前端传的参数名为host
-
保存后再次编辑数据源,ssh标签页中的使用ssh、主机两个字段为空 chat2db-server/chat2db-spi/src/main/java/ai/chat2db/spi/model/SSHInfo.java 与问题1类似,前端传参数名/类型与后端定义参数名/类型不一致
2.0.1已解决