Skip to content

fix: PathEscape project name in DMS to SQLE URLs#653

Open
LordofAvernus wants to merge 1 commit into
mainfrom
feat-936-project-chinese-name
Open

fix: PathEscape project name in DMS to SQLE URLs#653
LordofAvernus wants to merge 1 commit into
mainfrom
feat-936-project-chinese-name

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

User description

Summary

  • PathEscape project name when DMS builds SQLE URLs that place project_name in the path (db_service, CloudBeaver auto workflow).
  • Enables Chinese project names to work for downstream SQLE calls.

Test plan

  • Create Chinese-named project via API on quick-deploy
  • Verify DMS→SQLE path calls succeed for Chinese project names

Fixes actiontech/dms-ee#936


Description

  • 对项目名称进行 URL 编码

  • 修正 DMS 调用 SQLE API 路径构造

  • 确保中文项目名称正常传递


Diagram Walkthrough

flowchart LR
  A["修改 Cloudbeaver 与 DBService 文件"] -- "添加 URL 编码" --> B["使用 url.PathEscape 处理项目名称"]
Loading

File Walkthrough

Relevant files
Bug fix
cloudbeaver.go
修复 Cloudbeaver 中项目名称 URL 编码问题                                                       

internal/dms/biz/cloudbeaver.go

  • 添加 "net/url" 导入
  • 用 url.PathEscape 替换项目名称插入
  • 变量名由 url 更改为 reqURL
+3/-2     
db_service.go
修复 DBService 中项目名称 URL 编码问题                                                           

internal/dms/biz/db_service.go

  • 添加 "net/url" 导入
  • 用 url.PathEscape 对项目名称进行编码
  • 修正 API 请求的 URL 构造
+2/-1     

Encode project name path segments so Chinese project names work when
DMS calls SQLE APIs that use project_name in the URL.

Fixes actiontech/dms-ee#936
@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
检查项目名称有效性

建议在使用 url.PathEscape(projectName) 前,先验证 projectName 是否为空或无效,避免生成错误的 URL
并导致后续网络请求失败。该检查可防止因空字符串引起的不符合预期的行为。

internal/dms/biz/cloudbeaver.go [2345-2351]

+if projectName == "" {
+    return nil, fmt.Errorf("project name is empty")
+}
 reqURL := fmt.Sprintf("%s/v1/projects/%s/workflows/auto_create_and_execute", sqleUrl, url.PathEscape(projectName))
 if err := pkgHttp.Call(ctx, http.MethodPost, reqURL, headers, writer.FormDataContentType(), requestBody.Bytes(), &reply); err != nil {
Suggestion importance[1-10]: 7

__

Why: 该建议在生成请求 URL 前增加对 projectName 为空的校验,有助于提前捕获错误并防止后续网络请求失败,但改动幅度较小。

Medium
校验项目名称非空

建议在使用 url.PathEscape(project.Name) 前,先验证 project.Name 是否为空或无效,确保生成的 URL
格式正确。这样可以有效防止因空值导致的请求异常。

internal/dms/biz/db_service.go [421]

+if project.Name == "" {
+    return fmt.Errorf("project name is empty")
+}
 sqleAddr := fmt.Sprintf("%s/v2/projects/%s/instance_audit_plans", target.URL.String(), url.PathEscape(project.Name))
Suggestion importance[1-10]: 7

__

Why: 此建议在 URL 拼接前验证 project.Name 是否为空,从而提高了错误处理的稳健性,不过影响范围相对有限。

Medium

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.

1 participant