Skip to content

feat(sql_workbench): support GaussDB / PostgreSQL whitelist + fix /odc_query proxy fallback#631

Merged
Seechi-Yolo merged 2 commits into
mainfrom
dev-865
May 29, 2026
Merged

feat(sql_workbench): support GaussDB / PostgreSQL whitelist + fix /odc_query proxy fallback#631
Seechi-Yolo merged 2 commits into
mainfrom
dev-865

Conversation

@actiontech-bot
Copy link
Copy Markdown
Member

@actiontech-bot actiontech-bot commented May 26, 2026

User description

Summary

CE 部分,CE/EE 拆分自 actiontech/dms-ee#865(ODC 工作台支持 GaussDB / openGauss 需求)。

  • internal/sql_workbench/service/sql_workbench_service.go
    • SupportDBType 白名单新增 DBTypeGaussDB + DBTypePostgreSQL(覆盖 EARS-1.2 / decision-3 → KF-2)
    • convertDBType 新增 "GaussDB" → "GAUSSDB" 映射(EARS-1.3 / CR-12 case-sensitivity)
    • 单元测试新增 GaussDB / PG family / GaussDBForMySQL 等用例
  • internal/apiserver/service/router.go
    • 修复 static 中间件 Skipper 漏过 /odc_query 前缀,导致 DMS SPA fallback 拦截 ODC umi index.html
    • 新增 HasPrefix(GetRootUri()) 跳过逻辑,恢复 /odc_query/* → ODC :8989 反向代理

Related Issue

Refs: actiontech/dms-ee#865

Test plan

  • go vet ./internal/sql_workbench/service/... ./internal/apiserver/service/... 通过
  • dev 阶段在 EE dev 分支已跑过 SqlWorkbenchService 单测(13 case convertDBType + SupportDBType GaussDB/PG family 一致性)
  • CI checker job 通过
  • 联调 Demo-1 / Demo-2(dev/web_test 阶段已覆盖)

Description

  • 修复/odc_query路径代理问题

  • 更新转换函数支持GaussDB映射

  • 白名单新增PostgreSQL和GaussDB支持

  • 补充单元测试验证新逻辑


Diagram Walkthrough

flowchart LR
  A["更新SQL工作台支持"] --> B["添加GaussDB映射"]
  A --> C["白名单新增PostgreSQL与GaussDB"]
  D["路由中间件修复"] --> E["跳过/odc_query路径"]
Loading

File Walkthrough

Relevant files
Bug fix
router.go
修复/odc_query代理失败问题                                                                             

internal/apiserver/service/router.go

  • 新增跳过/odc_query判断,避免静态fallback错误返回DMS index.html
  • 优化中间件处理逻辑,确保ODC代理正常工作
+7/-0     
Enhancement
sql_workbench_service.go
添加GaussDB映射与白名单支持                                                                               

internal/sql_workbench/service/sql_workbench_service.go

  • 更新convertDBType函数,新增GaussDB映射
  • 修改SupportDBType函数,支持GaussDB和PostgreSQL进入白名单
+6/-2     
Tests
sql_workbench_service_test.go
补充GaussDB支持单元测试验证                                                                               

internal/sql_workbench/service/sql_workbench_service_test.go

  • 新增GaussDB测试用例验证转换函数
  • 增加测试保障PostgreSQL与GaussDB一致性
+16/-1   

…itelist

- SupportDBType: add DBTypeGaussDB + DBTypePostgreSQL to whitelist
  (EARS-1.2 / decision-3 positive coverage for KF-2)
- convertDBType: add "GaussDB" -> "GAUSSDB" mapping immediately after
  the existing "PostgreSQL" -> "POSTGRESQL" mapping (EARS-1.3 / CR-12
  case-sensitivity normalization)
- unit tests:
  - Test_convertDBType: new "GaussDB" case (13 total); existing
    "PostgreSQL" / "Unknown passthrough" regressed unchanged
  - Test_SupportDBType: flip "PostgreSQL" expected from false to true
    (decision-3 lock); new "GaussDB supported" + "GaussDBForMySQL
    unsupported" cases; existing SQL Server negative regression kept
  - Test_SupportDBType_GaussDB_PG_family_consistency: hard assertion
    PG family (PostgreSQL + GaussDB) whitelist coupling

Related: actiontech/dms-ee#865
The static middleware Skipper at internal/apiserver/service/router.go
only skipped /cloudbeaver, /provision/v, /sqle/v and /swagger paths.
Requests to /odc_query/ (with trailing slash), /odc_query/index.html
and any /odc_query/<spa-path> were intercepted by the DMS HTML5 SPA
fallback and got served as the DMS index.html (873B), instead of the
real ODC umi index.html (~11KB).

This broke the DMS UI 'SQL Workbench' entry whenever the link used
the trailing-slash form (`/odc_query/?dsId=...`). Without the fix
the browser landed on the DMS dashboard rather than the ODC SQL
workbench, even though API and subresource proxy targets at
`/odc_query/*` worked fine.

Add a HasPrefix check against
SqlWorkbenchController.SqlWorkbenchService.GetRootUri() (==/odc_query)
at the top of the Skipper so all `/odc_query` and `/odc_query/...`
requests bypass StaticConfig and reach the existing
ProxyWithConfig rewrite (`/odc_query/*` -> `/$1`) targeting ODC 8989.

Refs: dms-ee#865
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
增加空指针检查

建议在调用 s.SqlWorkbenchController.SqlWorkbenchService.GetRootUri() 前增加对
s.SqlWorkbenchController 及其 SqlWorkbenchService
的非空检查,以防止未初始化时调用导致空指针异常。这样可以避免在路由中出现潜在的 panic 问题。

internal/apiserver/service/router.go [458-460]

-if strings.HasPrefix(c.Request().URL.Path, s.SqlWorkbenchController.SqlWorkbenchService.GetRootUri()) {
+if s.SqlWorkbenchController != nil && s.SqlWorkbenchController.SqlWorkbenchService != nil &&
+   strings.HasPrefix(c.Request().URL.Path, s.SqlWorkbenchController.SqlWorkbenchService.GetRootUri()) {
 		return true
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly adds a nil-check on s.SqlWorkbenchController and its SqlWorkbenchService prior to calling GetRootUri(), which can prevent a potential nil pointer dereference. The improvement is useful for safety, although its overall impact on functionality is limited.

Medium

@Seechi-Yolo Seechi-Yolo merged commit f8fb414 into main May 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants