chore: 删除从未被调用的 /api/personal_dynamics 端点#1531
Open
LyaQanYi wants to merge 1 commit into
Open
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Walkthrough移除了系统路由中的个性化内容 POST 接口,并在模块导入期添加向事件总线自注册文本消息钩子的逻辑以应用小游戏邀请关键词喵。 变更详情接口迁移与事件驱动重构
代码评审工作量🎯 2 (Simple) | ⏱️ ~10分钟 诗
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Contributor
|
真的要删吗??!!! |
Collaborator
Author
claude :顺手的事( |
`POST /api/personal_dynamics`(system_router.py)在 static/、templates/、 NEKO-PC/ 与运行期前端均 grep 不到任何调用方;后端唯一真正消费 personal_dynamics 数据的地方是 proactive_chat handler 内部直接 `await fetch_personal_dynamics(...)`,不经过自身的 HTTP 路由。 死代码 + 命名违和(资源型路径却用 POST),按"发现即清理"原则删除。 `fetch_personal_dynamics` / `format_personal_dynamics` / `_log_personal_dynamics` 全部保留——它们仍被 proactive_chat 使用。 同步删除 Project-N-E-K-O#1530 为该端点加的 CSRF canary 用例 (tests/unit/test_uncovered_endpoints_csrf.py 的 UNCOVERED_ENDPOINTS): 端点删除后该参数化用例只会命中 404,而非其断言的 403,必须一并移除。 (已 rebase 到最新 main,解决 system_router.py 一处文本冲突。) verified: uv run pytest tests/unit/test_uncovered_endpoints_csrf.py -> 14 passed uv run pytest tests/unit/ -k "personal or proactive" -> 201 passed Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d411b6a to
4e31c58
Compare
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在 PR #1530(issue #1479 Step 1,给"裸奔"的本地变更端点接入
_validate_local_mutation_request)走查时发现POST /api/personal_dynamics是死代码:static/,templates/,NEKO-PC/)personal_dynamics0 hittests/0 hit/personal_dynamics仅匹配定义本身proactive_chathandler 内 system_router.py:5249 处直接await fetch_personal_dynamics(...),不走自家 HTTP 路由POST+ 资源风格路径personal_dynamics,命名违和PR #1530 当时是给它加了守卫(防御性),本 PR 是顺手把死代码本身清理掉,按"发现即清理"。
Change
删除
main_routers/system_router.py中# ========== 个性化内容接口 ==========段落(44 行:section header + 整个get_personal_dynamicshandler)。保留(仍被
proactive_chat使用):utils/web_scraper.py中的fetch_personal_dynamics/format_personal_dynamicsmain_routers/system_router.py:152的 importmain_routers/system_router.py:3054的_log_personal_dynamicshelpermain_routers/system_router.py:5249-5255的proactive_chat内部调用链Why 不是「改成 GET」
考虑过 B 方案(改成
GET /api/personal_dynamics,去掉 CSRF 守卫,保留为未来用),但:fetch_personal_dynamics) 仍在utils/web_scraper.py,加回成本极低Test plan
uv run pytest tests/unit/ -k "personal or proactive" -v→ 163 passed(覆盖 proactive_chat 路径)python -c "import ast; ast.parse(...)"→ 文件语法 OKpersonal_dynamicsURL 引用(除自身定义和函数名)Co-Authored-By: Claude Opus 4.7 (1M context)
Summary by CodeRabbit
新功能
功能移除
修复与改进