Skip to content

<feat>[zwatch]: add GlobalErrorCode and i18n translations for external alert integration#3763

Open
zstack-robot-2 wants to merge 1 commit into5.5.12from
sync/lin.ma/zcf_endpoint@@2
Open

<feat>[zwatch]: add GlobalErrorCode and i18n translations for external alert integration#3763
zstack-robot-2 wants to merge 1 commit into5.5.12from
sync/lin.ma/zcf_endpoint@@2

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Add error codes ORG_ZSTACK_ZWATCH_ALARM_10030 (invalid URL) and
ORG_ZSTACK_ZWATCH_ALARM_10031 (endpoint not found) with 10-language
i18n translations for the external alert integration API interceptor.

Resolves: ZCF-991

Change-Id: I61657078726f6168766d79626c64727865736d63

sync from gitlab !9632

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: df5ca0f0-8145-416f-b383-15761f69d618

📥 Commits

Reviewing files that changed from the base of the PR and between 9c1c60c and 1c09305.

⛔ Files ignored due to path filters (16)
  • conf/i18n/globalErrorCodeMapping/global-error-de-DE.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-en_US.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-fr-FR.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-id-ID.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-ja-JP.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-ko-KR.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-ru-RU.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-th-TH.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-zh_CN.json is excluded by !**/*.json
  • conf/i18n/globalErrorCodeMapping/global-error-zh_TW.json is excluded by !**/*.json
  • sdk/src/main/java/org/zstack/sdk/zwatch/alarm/integration/CheckExternalAlertIntegrationAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/zwatch/alarm/integration/CheckExternalAlertIntegrationResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/zwatch/alarm/integration/RemoveExternalAlertIntegrationAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/zwatch/alarm/integration/RemoveExternalAlertIntegrationResult.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/zwatch/alarm/integration/SetupExternalAlertIntegrationAction.java is excluded by !sdk/**
  • sdk/src/main/java/org/zstack/sdk/zwatch/alarm/integration/SetupExternalAlertIntegrationResult.java is excluded by !sdk/**
📒 Files selected for processing (2)
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
  • utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
✅ Files skipped from review due to trivial changes (1)
  • utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy

Walkthrough

CloudOperationsErrorCode 中新增一项公共常量;在 ApiHelper.groovy 中新增三项外部告警集成的 helper 方法(check/remove/setup),包含 sessionId 设置、Closure 参数填充,以及在 -Dapipath 存在时对 apiId 的填充与请求路径记录逻辑。

Changes

Cohort / File(s) Summary
告警错误代码常量
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java
新增单个公共常量:ORG_ZSTACK_ZWATCH_ALARM_10030(字面量字符串赋值)。
测试 API helper:外部告警集成
testlib/src/main/java/org/zstack/testlib/ApiHelper.groovy
新增三方法:checkExternalAlertIntegrationremoveExternalAlertIntegrationsetupExternalAlertIntegration。每方法:实例化对应 SDK Action、设置 sessionId、执行传入 Closure(OWNER_FIRST)以填充参数;若 System.getProperty("apipath") != null 则在缺失时设置 apiIdPlatform.uuid()),通过 ApiPathTracker 跟踪并记录 Test.apiPaths,否则直接执行并返回 errorOut(a.call())。并含少量空白格式调整。

Sequence Diagram(s)

sequenceDiagram
    rect rgba(200,200,255,0.5)
    participant Test as 测试用例
    end
    rect rgba(200,255,200,0.5)
    participant Helper as ApiHelper
    end
    rect rgba(255,200,200,0.5)
    participant Action as SDKAction
    end
    rect rgba(255,255,200,0.5)
    participant Platform as Platform
    end

    Test->>Helper: 调用 setup/check/removeExternalAlertIntegration(Closure)
    Helper->>Action: 实例化对应 Action 并设置 sessionId
    Helper->>Helper: 执行 Closure (OWNER_FIRST) 填入参数
    alt apipath system property 存在
        Helper->>Platform: 若无 apiId 则调用 Platform.uuid() 生成 apiId
        Helper->>Helper: 用 ApiPathTracker 跟踪并将路径写入 Test.apiPaths
        Helper->>Action: 调用 a.call()
        Action-->>Helper: 返回结果
    else 无 apipath
        Helper->>Action: 直接调用 a.call()
        Action-->>Helper: 返回结果
    end
    Helper-->>Test: 返回或包装并返回结果(errorOut(...))
Loading

代码审查工作量估计

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 新常量轻轻来,
三路小助填参数,
apipath 在则记足迹,
问答往返不徘徊,
小兔挥手庆改动。


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Title check ❌ Error 标题超过了72字符的限制(88字符),格式不符合要求。 请将标题缩短至72字符以内,例如:[zwatch]: Add error codes for external alert integration
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed 描述与变更集相关,清晰说明了添加的错误代码和i18n翻译的目的。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/lin.ma/zcf_endpoint@@2

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
utils/src/main/java/org/zstack/utils/clouderrorcode/CloudOperationsErrorCode.java

Comment @coderabbitai help to get the list of available commands and usage tips.

@MatheMatrix MatheMatrix force-pushed the sync/lin.ma/zcf_endpoint@@2 branch 2 times, most recently from 9deef0e to 9c1c60c Compare April 16, 2026 01:42
@ZStack-Robot
Copy link
Copy Markdown
Collaborator

Comment from ye.zou:

Code Review

LGTM ✅ 没看到会阻塞合入的问题。

纯数据/生成代码 MR:10 个 i18n JSON 文件各加 2 条 error code(10030/10031),SDK Action/Result 类为标准生成模板,ApiHelper.groovy 为标准生成代码,CloudOperationsErrorCode 加两个常量。error code 编号连续无冲突,i18n 翻译质量可接受。

结论: APPROVE ✅
回归风险: 低

…rnal alert integration

Add error code ORG_ZSTACK_ZWATCH_ALARM_10030 (invalid URL) with
10-language i18n translations for the external alert integration
API interceptor URL validation.

Resolves: ZSTAC-84319

Change-Id: I61657078726f6168766d79626c64727865736d63
@MatheMatrix MatheMatrix force-pushed the sync/lin.ma/zcf_endpoint@@2 branch from 9c1c60c to 1c09305 Compare April 16, 2026 09:11
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.

2 participants