Repository navigation
refactor: delete the unused discord_svr.py bot script - #17682
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe pull request deletes the Discord bot module and removes its path from Ruff's exclusion list. ChangesDiscord server removal
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change removes an unused legacy bot script and its obsolete lint exclusion without altering active Discord integrations or dependencies; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.) 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/svr/discord_svr.py`:
- Around line 54-56: Update the completion call around session.post and the
image creation/send flow to add non-sensitive logs: record HTTP status and
request latency for the completion request, and log whether image creation and
sending succeed or fail. Do not include JSON_DATA, Authorization, message
content, or image bytes in any log messages.
- Around line 54-56: Update the Discord bot lifecycle and mention handler around
the aiohttp request to reuse one shared ClientSession configured with an
explicit ClientTimeout instead of creating a session per mention; call
response.raise_for_status(), catch timeout and aiohttp.ClientError failures, and
send the existing fallback response for those errors. Add mocked tests covering
request timeouts and non-2xx responses.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e959ba4-7331-4063-be55-b5565408e2e3
📒 Files selected for processing (1)
rag/svr/discord_svr.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rag/svr/discord_svr.py (1)
57-59: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winBuild a request-local payload.
When two
on_messagehandlers overlap, Line 56 mutates the same module-level dictionary that Line 59 passes toaiohttp. Pass a per-request dictionary instead. This removes shared mutable request state and prevents prompt mix-ups if request setup yields before payload serialization or changes later.Proposed fix
- JSON_DATA['word'] = message.content.split('> ')[1] + request_data = { + **JSON_DATA, + 'word': message.content.split('> ')[1], + } ... - async with session.post(URL, json=JSON_DATA) as response: + async with session.post(URL, json=request_data) as response:Verify this with a concurrency test that asserts each request receives its own
word.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/svr/discord_svr.py` around lines 57 - 59, Update the on_message request setup to construct a fresh payload dictionary for each invocation, and pass that request-local payload to session.post instead of the shared module-level JSON_DATA. Preserve the per-request word value and add a concurrency test verifying overlapping requests receive their own word.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rag/svr/discord_svr.py`:
- Around line 57-59: Update the on_message request setup to construct a fresh
payload dictionary for each invocation, and pass that request-local payload to
session.post instead of the shared module-level JSON_DATA. Preserve the
per-request word value and add a concurrency test verifying overlapping requests
receive their own word.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b3eb0bd9-f90b-448a-ad24-349e15451cb3
📒 Files selected for processing (1)
rag/svr/discord_svr.py
6ba3i
left a comment
There was a problem hiding this comment.
Thank you for your help! unfortunately discord_svr.py is legacy code that isn't being used anymore, could you make the change of deleting the file.
Per review on infiniflow#17682: rag/svr/discord_svr.py is legacy and no longer used. It is a standalone script (module-level client.start() at import time) with placeholder credentials baked in; nothing in the tree imports it. The only remaining reference anywhere was the ruff exclude in pyproject.toml, which is dropped with it. The `discord-py` dependency stays: common/data_source/discord_connector.py and api/channels/discord/channel.py both still import the package, so the audioop-lts note in [project].dependencies is still load-bearing on 3.13. Verified with `grep -rn discord_svr .` -> no hits after the change.
c68adbd to
e8a63c7
Compare
|
@6ba3i Done — the PR is now the deletion you asked for instead of the event-loop patch. Rebased onto current I left |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17682 +/- ##
==========================================
- Coverage 39.25% 39.09% -0.17%
==========================================
Files 54 54
Lines 14911 14911
Branches 117 117
==========================================
- Hits 5854 5829 -25
- Misses 9045 9056 +11
- Partials 12 26 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Replaces the original event-loop fix on
rag/svr/discord_svr.pywith a deletion, per @6ba3i's review: the file is legacy and no longer used.What the file was: a standalone script with placeholder credentials hardcoded at module level (
URL = '{YOUR_IP_ADDRESS:PORT}/...',DISCORD_BOT_KEY = "xxxx"), callingloop.run_until_complete(client.start(...))at import time. Nothing in the tree imports it.Also drops the now-dangling ruff exclude that pointed at it:
That exclude was the only remaining reference to the file anywhere in the repo. Checked with
grep -rn discord_svr . --exclude-dir=.git— zero hits after the change.The
discord-pydependency is not removed.common/data_source/discord_connector.pyandapi/channels/discord/channel.pyboth still import the package, so theaudioop-ltsentry and its Python 3.13 note in[project].dependenciesstay load-bearing.Branch was rebased onto current
main(it was 655 commits behind), so the diff is now just the two changes above.