Skip to content

feat: add Feishu SDK DM notification support - #1221

Closed
loopoook wants to merge 1 commit into
ZhuLinsen:mainfrom
loopoook:feat/feishu-dm-notify
Closed

feat: add Feishu SDK DM notification support#1221
loopoook wants to merge 1 commit into
ZhuLinsen:mainfrom
loopoook:feat/feishu-dm-notify

Conversation

@loopoook

@loopoook loopoook commented May 7, 2026

Copy link
Copy Markdown
  • Add FEISHU_USER_ID config for direct message push via Feishu app SDK
  • When FEISHU_APP_ID + FEISHU_APP_SECRET + FEISHU_USER_ID are all set, reports are sent as DM instead of requiring a group webhook
  • Falls back to webhook mode when SDK config is not available
  • Update .env.example, CHANGELOG.md, and feishu-bot-config.md

PR Type

  • fix
  • feat
  • refactor
  • docs
  • chore
  • test

Background And Problem

请描述当前问题、影响范围与触发场景。
(EN) Describe the problem, its impact, and what triggers it.

Scope Of Change

请列出本 PR 修改的模块和文件范围。
(EN) List the modules and files changed in this PR.

Issue Link

必须填写以下之一 / Fill in one of:

  • Fixes #<issue_number>
  • Refs #<issue_number>
  • 无 Issue 时说明原因与验收标准 / If no issue, explain the motivation and acceptance criteria

Verification Commands And Results

请填写你实际执行过的命令和关键结果(不要只写"已测试")。
(EN) Paste the commands you actually ran and their key output (don't just write "tested"):

# example
./scripts/ci_gate.sh
python -m pytest -m "not network"

关键输出/结论 / Key output & conclusion:

Compatibility And Risk

请说明兼容性影响、潜在风险(如无请写 None)。
(EN) Describe compatibility impact and potential risks (write None if not applicable).

  • 若本 PR 修改第三方模型 / API 的兼容语义、请求参数、路由前缀或 provider fallback,请提供官方来源链接或公告,并说明这是长期约束、当前运行时约束还是临时兼容处理。
    (EN) If this PR changes third-party model/API compatibility, request parameters, routing prefixes, or provider fallback behavior, include an official source link or announcement and clarify whether the rule is permanent, runtime-specific, or a temporary compatibility workaround.)
  • 若本 PR 依赖特定运行时 / 锁定依赖窗口(例如 LiteLLM 版本范围、OpenAI-compatible 路由、YAML alias 行为),请写明当前验证过的兼容范围与覆盖路径。
    (EN) If this PR depends on a specific runtime or pinned dependency window (for example a LiteLLM version range, OpenAI-compatible routing, or YAML alias behavior), state the compatibility window you verified and which code paths were covered.)
  • 若本 PR 触及运行时配置保存、清理、迁移或回填逻辑,请明确说明旧配置是否会被自动改写、清空、迁移或保持不变,以及用户如何恢复原行为。
    (EN) If this PR touches runtime config save/cleanup/migration/backfill logic, explicitly describe whether existing config is rewritten, cleared, migrated, or left intact, and how users can restore the previous behavior.)

Rollback Plan

请至少写一句可执行的回滚方案(必填)。
(EN) Provide at least one actionable rollback step (required).

  • 如果是兼容性修复,默认应写出最小回滚方式(例如 revert this PR),并说明是否需要额外回滚配置或数据迁移。
    (EN) For compatibility fixes, include the minimal rollback path (for example revert this PR) and whether any additional config or data rollback is required.)

EXTRACT_PROMPT Change (if applicable)

若本 PR 修改了 src/services/image_stock_extractor.py 中的 EXTRACT_PROMPT,请在此处粘贴完整变更后的 prompt。
If this PR changes EXTRACT_PROMPT in src/services/image_stock_extractor.py, paste the full updated prompt here:

展开 / Expand: Full EXTRACT_PROMPT
(paste full prompt here)

Checklist

  • 本 PR 有明确动机和业务价值 / This PR has a clear motivation and value
  • 已提供可复现的验证命令与结果 / Reproducible verification commands and results are included
  • 已评估兼容性与风险 / Compatibility and risk have been assessed
  • 已提供回滚方案 / A rollback plan is provided
  • 若涉及用户可见变更,已同步更新相关文档与 docs/CHANGELOG.mdREADME.md 仅在首页级信息变化时更新,细节优先写入 docs/*.md / If user-visible changes are included, relevant docs and docs/CHANGELOG.md are updated; README.md is updated only for homepage-level changes, with details kept in docs/*.md

- Add FEISHU_USER_ID config for direct message push via Feishu app SDK
- When FEISHU_APP_ID + FEISHU_APP_SECRET + FEISHU_USER_ID are all set,
  reports are sent as DM instead of requiring a group webhook
- Falls back to webhook mode when SDK config is not available
- Update .env.example, CHANGELOG.md, and feishu-bot-config.md
@loopoook
loopoook requested a review from ZhuLinsen as a code owner May 7, 2026 11:16
@github-actions github-actions Bot added configuration documentation Improvements or additions to documentation feishu notification size/L labels May 7, 2026
@loopoook loopoook closed this May 7, 2026
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 5 个
➕ 新增行数 288 行
➖ 删除行数 76 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 .env.example (+4/-1)
  • 📝 docs/CHANGELOG.md (+1/-0)
  • 📝 docs/bot/feishu-bot-config.md (+16/-0)
  • 📝 src/config.py (+2/-0)
  • 📝 src/notification_sender/feishu_sender.py (+265/-75)

🧠 AI 代码审查意见

PR 审查结果

结论: Not Ready

结构化结果

  • 必要性通过
    • 该功能增加了飞书私聊通知的能力,为用户提供了更灵活的通知方式,避免了必须创建群机器人 Webhook 的限制,具有明确的用户价值和业务价值。
  • 关联性不通过
    • PR 描述中缺少 Issue 链接,也未说明无 Issue 时的原因和验收标准。
  • 类型feat (新功能)。
    • PR 类型与变更内容相符,本次变更引入了飞书 SDK 私聊通知这一新功能。
  • 描述完整性不完整
    • PR 描述中以下关键部分为空白:
      • Background And Problem
      • Scope Of Change
      • Verification Commands And Results
      • Compatibility And Risk
      • Rollback Plan
    • Checklist 未完成。
  • 风险级别
    • 存在一个功能性缺陷,未能正确加载必要的配置项,导致新功能无法按预期工作。同时,缺少验证结果和兼容性评估,增加了潜在的运行时风险。

必改项 (阻断项)

  1. 功能性缺陷:飞书 App ID 和 Secret 未加载到配置对象

    • 文件src/config.py
    • 问题描述src/notification_sender/feishu_sender.py 中的 FeishuSender 类在初始化时尝试通过 getattr(config, 'feishu_app_id', None)getattr(config, 'feishu_app_secret', None) 获取飞书应用 ID 和 Secret。然而,src/config.py 中的 Config 类定义和 from_env 方法均未包含 feishu_app_idfeishu_app_secret 这两个字段,也未从环境变量中加载它们。
    • 影响:这将导致 FeishuSender 始终无法获取到 FEISHU_APP_IDFEISHU_APP_SECRET,从而使得飞书 SDK 私聊推送功能无法正常工作,因为 SDK 客户端无法用 None 进行初始化。
    • 修改建议
      1. src/config.pyConfig 类中,添加 feishu_app_id: Optional[str] = Nonefeishu_app_secret: Optional[str] = None
      2. src/config.pyfrom_env 方法中,通过 os.getenv('FEISHU_APP_ID')os.getenv('FEISHU_APP_SECRET') 加载这两个配置项。
  2. 缺少验证命令与结果

    • 文件PR 描述
    • 问题描述:PR 描述中 "Verification Commands And Results" 部分为空。未能提供实际执行的命令和关键结果,无法确认新功能(飞书 SDK 私聊通知)是否已充分验证,特别是针对 SDK 私聊和 Webhook 回退两种模式的测试。
    • 影响:功能正确性无法得到充分保证,增加了合入后的潜在风险。
    • 修改建议:请补充详细的验证步骤、实际执行的命令及关键输出/结论,以证明新功能在不同配置下均能正常工作。
  3. 缺少回滚方案

    • 文件PR 描述
    • 问题描述:PR 描述中 "Rollback Plan" 部分为空,未提供可执行的回滚方案。
    • 影响:若合入后出现问题,将缺乏明确的回滚指引,影响故障恢复效率。
    • 修改建议:请提供至少一个可执行的回滚步骤,例如 revert this PR,并说明是否需要额外回滚配置或数据迁移。

建议项

  1. 补充 PR 描述完整性
    • 文件PR 描述
    • 问题描述:"Background And Problem"、"Scope Of Change" 和 "Compatibility And Risk" 均为空白。
    • 修改建议:请补充这些部分,以提供更全面的 PR 上下文、变更影响范围和潜在的兼容性与风险评估。
  2. 完成 Checklist
    • 文件PR 描述
    • 问题描述:PR Checklist 未勾选。
    • 修改建议:请根据实际情况勾选 Checklist,确保所有必要的审查点都已自检。
  3. 补充 Issue 关联信息
    • 文件PR 描述
    • 问题描述:PR 描述中 "Issue Link" 为空。
    • 修改建议:如果有相关 Issue,请填写 Fixes #<issue_number>Refs #<issue_number>;如果没有,请说明未创建 Issue 的动机和验收标准。
  4. 关于 scripts/ci_gate.sh 的说明
    • 文件PR 描述
    • 问题描述:本 PR 修改了 Python 后端代码,但 PR 描述中未说明是否执行了 ./scripts/ci_gate.sh 命令或给出跳过原因。
    • 修改建议:请在 "Verification Commands And Results" 部分说明是否已执行 ./scripts/ci_gate.sh,如果执行了,请提供关键输出或结论;如果因故未执行,请说明原因。

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0725e94df4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +147 to +148
if self._use_sdk:
return self._send_via_sdk(content)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add SDK-only Feishu configs to channel detection

When users follow the new SDK-only setup (FEISHU_APP_ID + FEISHU_APP_SECRET + FEISHU_USER_ID, no webhook), this branch is never reached through the normal notification flow: NotificationService.detect_configured_channels only appends NotificationChannel.FEISHU when feishu_webhook_url is set, so send() returns early as unavailable and the pipeline is_available() gate also skips notifications. Please update channel detection/setup checks to treat the SDK private-chat configuration as a Feishu channel; otherwise the documented “no webhook” mode silently does not send reports.

Useful? React with 👍 / 👎.

@loopoook
loopoook deleted the feat/feishu-dm-notify branch May 7, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant