Skip to content

fix(webhook): support Feishu v2 and redact secrets - #144

Draft
ZeroPointSix wants to merge 4 commits into
mainfrom
codexweb/fix-feishu-webhook-v2-20260811
Draft

fix(webhook): support Feishu v2 and redact secrets#144
ZeroPointSix wants to merge 4 commits into
mainfrom
codexweb/fix-feishu-webhook-v2-20260811

Conversation

@ZeroPointSix

Copy link
Copy Markdown
Owner

Pull request type / PR 类型

  • Bugfix / Bug 修复
  • Feature / 新功能
  • Code style update (formatting, renaming) / 代码风格更新(格式化、重命名)
  • Refactoring (no functional changes, no api changes) / 重构(无功能更改、无 API 更改)
  • Build related changes / 构建相关更改
  • Documentation content changes / 文档内容更改

What is the current behavior? / 当前行为是什么?

Railway 上的两个实例共用同一发送实现。该实现固定用 text/plain 投递,飞书自定义机器人 v2 Webhook 返回 HTTP 400 / code 9499。失败日志还会保留完整 URL 路径,导致 /hook/<密钥> 暴露。

What is the new behavior? / 新行为是什么?

  • 自动识别 open.feishu.cnopen.larksuite.com/open-apis/bot/v2/hook/ 地址,按官方协议发送 application/json; charset=utf-8{"msg_type":"text","content":{"text":"..."}}
  • 其他通用 Webhook 保持 text/plain,现有可选 X-Webhook-Token 行为不变。
  • 日志与测试接口只保留主机和 <redacted>;请求异常、响应正文、URL 路径、查询参数、片段和 userinfo 不再进入日志。
  • 补丁版本升级为 2.8.1,无数据库迁移。

官方协议依据:飞书自定义机器人使用指南

Verification / 验证

  • python -m py_compile:目标服务与测试文件通过。
  • 隔离定向回归:8/8 通过,覆盖飞书/Lark v2 payload、通用协议兼容、相似域名防误判及三类脱敏。
  • GitHub Code QualityPython Tests:PR 创建后等待执行。

Deployment boundary / 部署边界

本 PR 不合并、不打 tag、不发布镜像、不部署 Railway,也不轮换 Webhook 密钥。生产操作需另行明确授权与凭证。

Copy link
Copy Markdown
Owner Author

验证更新:

  • Code Quality:通过。Black、isort、Flake8、mypy、Bandit 全部成功。
  • Python Tests:通过。Python 3.11 / 3.12 / 3.13 均运行 1601 tests,结果 OK (skipped=13),覆盖率 87%。
  • SonarCloud:测试与覆盖率步骤成功,但扫描器连续两次在源码分析前失败,固定错误为 Something went wrong while trying to get the pullrequest with key '144'。该失败属于 SonarCloud ↔ GitHub ALM 的 PR 元数据读取问题,不是代码分析或测试失败;按止损规则不再原样重跑。

PR 保持草稿,未合并、未打 tag、未部署 Railway、未轮换 Webhook 密钥。

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