chore: notify on new GitHub issues#21836
Conversation
📝 WalkthroughWalkthrough新增 GitHub Actions 工作流,在 ChangesIssue Webhook 通知
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: 失败后最多重试三次
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| 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" |
There was a problem hiding this comment.
🩺 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' || trueRepository: 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:
- 1: fix: auto-detect Feishu webhook format and validate response body cita-777/metapi#271
- 2: https://open.larksuite.com/document/client-docs/bot-v3/add-custom-bot
- 3: https://open.larkoffice.com/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN
- 4: https://github.com/openclaudia/openclaudia-skills/blob/main/skills/feishu-lark/SKILL.md
- 5: https://github.com/ysyecust/claude-lark/blob/main/claude_lark_notify.py
校验 Webhook 返回的 code,不要只依赖 HTTP 状态码。
Feishu/Lark 自定义机器人即使 HTTP 200 也可能返回非零业务失败码(如参数错误、签名错误、限流等),只有 code == 0 才表示消息发送成功。当前命令在业务失败时仍会把工作流标为成功;应保存响应体并校验 .code == 0,失败时打印响应并退出,必要时将可重试码纳入现有重试逻辑。
Source: MCP tools
What is changed, added or deleted? (Required)
Add an Issue notification workflow that:
GITHUB_TOKENpermissionsWhich 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).
What is the related PR or file link(s)?
AI agent involvement
Do your changes match any of the following descriptions?
Summary by CodeRabbit