Skip to content

chore: notify on new GitHub issues#21836

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
qiancai:monitor-issue
Jul 26, 2026
Merged

chore: notify on new GitHub issues#21836
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
qiancai:monitor-issue

Conversation

@qiancai

@qiancai qiancai commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

What is changed, added or deleted? (Required)

Add an Issue notification workflow that:

  • sends a webhook notification when an Issue is opened
  • includes the Issue number, title, URL, reporter, and assignees
  • removes all GITHUB_TOKEN permissions
  • retries transient webhook failures with bounded request timeouts

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • 新功能
    • 新增 Issue 创建通知:当仓库中新建 Issue 时,自动发送包含创建日期、编号、标题、链接、创建者与受让人信息的通知。
    • 发送失败会进行重试,最多尝试 3 次以提升消息送达的可靠性。

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

新增 GitHub Actions 工作流,在 pingcap/docs-cn 创建新 Issue 时生成包含 Issue 信息的文本 JSON,并通过 Webhook 发送;请求失败时最多重试三次。

Changes

Issue Webhook 通知

Layer / File(s) Summary
工作流触发与运行条件
.github/workflows/bot.yaml
工作流监听 issues: opened 事件,禁用默认权限,并限制 notify 作业仅在目标仓库运行;同时准备 Issue 和 Webhook 环境变量。
消息生成与 Webhook 重试
.github/workflows/bot.yaml
组装 Issue 通知文本并使用 jq 生成 JSON payload,通过 curl 发送请求,失败时等待 5 秒并最多重试三次。

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubIssues
  participant GitHubActions
  participant Webhook
  GitHubIssues->>GitHubActions: 触发 issues opened
  GitHubActions->>GitHubActions: 构造 Issue 通知 JSON
  GitHubActions->>Webhook: POST Webhook 请求
  Webhook-->>GitHubActions: 返回请求结果
  GitHubActions->>Webhook: 失败后最多重试三次
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题简洁且准确概括了为新 GitHub Issue 添加通知的主要变更。
Description check ✅ Passed 描述已包含变更内容、适用版本和相关链接,且与模板要求基本一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@qiancai qiancai self-assigned this Jul 26, 2026
@qiancai qiancai added the translation/no-need No need to translate this PR. label Jul 26, 2026
@ti-chi-bot ti-chi-bot Bot removed the missing-translation-status This PR does not have translation status info. label Jul 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4f7dfa0d-5eec-4f2f-9fa1-ecbb1b8c025b

📥 Commits

Reviewing files that changed from the base of the PR and between 400a865 and 9d80437.

📒 Files selected for processing (1)
  • .github/workflows/bot.yaml

Comment thread .github/workflows/bot.yaml Outdated
@qiancai

qiancai commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

/approve

@qiancai qiancai added the lgtm label Jul 26, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiancai

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Jul 26, 2026
@qiancai qiancai added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 136a985c-c6d1-43d6-878d-1dc3993c7785

📥 Commits

Reviewing files that changed from the base of the PR and between 9d80437 and 28506a7.

📒 Files selected for processing (1)
  • .github/workflows/bot.yaml

Comment on lines +39 to +49
curl --connect-timeout 10 \
--fail-with-body \
--header "Content-Type: application/json" \
--max-time 30 \
--retry 2 \
--retry-connrefused \
--retry-delay 5 \
--show-error \
--silent \
--data-binary "$payload" \
"$WEBHOOK_URL"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow sample =="
sed -n '1,120p' .github/workflows/bot.yaml 2>/dev/null || true

echo
echo "== webhook mentions =="
rg -n "WEBHOOK_URL|webhook|费书|飞书|lark|Feishu|code|curl|fail-with-body" .github/workflows/bot.yaml .github/workflows 2>/dev/null || true

echo
echo "== changed files summary =="
git diff --stat 2>/dev/null || true
git diff -- .github/workflows/bot.yaml 2>/dev/null | sed -n '1,220p' || true

Repository: pingcap/docs-cn

Length of output: 3300


🌐 Web query:

Feishu Lark webhook JSON response fields 0 success 200 bad response code

💡 Result:

When calling a Feishu/Lark custom bot webhook, the API returns an HTTP 200 status code even if the request payload is malformed or invalid [1]. Because the HTTP status code alone does not indicate whether the operation was truly successful, you must inspect the code field within the returned JSON body to verify the result [1][2]. A successful message delivery is explicitly indicated by a code value of 0 [3][4][2]. If the code is non-zero, the request has failed [1][2][5]. The standard success response structure is as follows: { "code": 0, "msg": "success", "data": {} } Common error responses, which still return HTTP 200, include: - Code 9499: Bad Request (malformed JSON or missing required fields) [3][4][2] - Code 19001: Param invalid (invalid msg_type or content format) [4] - Code 19002: Sign match fail (signature verification error) [4] - Code 19021: Request too fast (rate limit exceeded) [4] - Code 19024: Bot not in chat (bot removed from the group) [4] Note that fields like StatusCode and StatusMessage may appear in the response but are considered redundant legacy fields and should not be used for logic [3][2]. Always prioritize the code field for error handling [1][5].

Citations:


校验 Webhook 返回的 code,不要只依赖 HTTP 状态码。

Feishu/Lark 自定义机器人即使 HTTP 200 也可能返回非零业务失败码(如参数错误、签名错误、限流等),只有 code == 0 才表示消息发送成功。当前命令在业务失败时仍会把工作流标为成功;应保存响应体并校验 .code == 0,失败时打印响应并退出,必要时将可重试码纳入现有重试逻辑。

Source: MCP tools

@qiancai qiancai removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 480e3ab into pingcap:master Jul 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant