Skip to content

refactor: delete the unused discord_svr.py bot script - #17682

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
noron12234:fix/discord-bot-blocking-http
Aug 28, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
noron12234:fix/discord-bot-blocking-http

Conversation

@noron12234

@noron12234 noron12234 commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the original event-loop fix on rag/svr/discord_svr.py with 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"), calling loop.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:

-exclude = [".venv", "rag/svr/discord_svr.py"]
+exclude = [".venv"]

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-py dependency is not removed. common/data_source/discord_connector.py and api/channels/discord/channel.py both still import the package, so the audioop-lts entry and its Python 3.13 note in [project].dependencies stay load-bearing.

Branch was rebased onto current main (it was 655 commits behind), so the diff is now just the two changes above.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d7e16af8-eec1-45e0-abe7-fb7bdc79b3cd

📥 Commits

Reviewing files that changed from the base of the PR and between 88e80fc and e8a63c7.

📒 Files selected for processing (2)
  • pyproject.toml
  • rag/svr/discord_svr.py
💤 Files with no reviewable changes (1)
  • rag/svr/discord_svr.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The pull request deletes the Discord bot module and removes its path from Ruff's exclusion list.

Changes

Discord server removal

Layer / File(s) Summary
Discord bot deletion and lint configuration
rag/svr/discord_svr.py, pyproject.toml
The Discord bot implementation was deleted. Ruff now includes the former module path in its lint configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e8a63

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: rayhanest, asiroliu

Poem

A rabbit checks the empty nest,
The Discord bot has gone to rest.
Ruff now scans the path anew,
With fewer lines to review.
Clean config marks the change complete.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed 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…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes the required Summary section and clearly explains the deletion, Ruff configuration change, retained dependency, and repository impact.
Title check ✅ Passed The title clearly and concisely describes the primary change: deleting the unused discord_svr.py bot script.
Full details: Docstring Coverage

Explanation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8db965f and 8ed12eb.

📒 Files selected for processing (1)
  • rag/svr/discord_svr.py

Comment thread rag/svr/discord_svr.py Resolved
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
rag/svr/discord_svr.py (1)

57-59: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Build a request-local payload.

When two on_message handlers overlap, Line 56 mutates the same module-level dictionary that Line 59 passes to aiohttp. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed12eb and 23ad260.

📒 Files selected for processing (1)
  • rag/svr/discord_svr.py

@JinHai-CN
JinHai-CN requested a review from 6ba3i August 25, 2026 04:27

@6ba3i 6ba3i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.
@noron12234
noron12234 force-pushed the fix/discord-bot-blocking-http branch from c68adbd to e8a63c7 Compare August 27, 2026 16:52
@noron12234 noron12234 changed the title fix(discord): don't block the event loop in the message handler refactor: delete the unused discord_svr.py bot script Aug 27, 2026
@noron12234

Copy link
Copy Markdown
Contributor Author

@6ba3i Done — the PR is now the deletion you asked for instead of the event-loop patch. Rebased onto current main first, so the diff is 2 files: rag/svr/discord_svr.py removed, plus the [tool.ruff] exclude in pyproject.toml that pointed at it (the only other reference in the tree).

I left discord-py in pyproject.toml on purpose — common/data_source/discord_connector.py and api/channels/discord/channel.py still import it, so the audioop-lts 3.13 workaround is still needed. Say the word if you want those looked at separately.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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.

@6ba3i
6ba3i self-requested a review August 28, 2026 05:04

@6ba3i 6ba3i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 28, 2026
@6ba3i 6ba3i added the ci Continue Integration label Aug 28, 2026
@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.09%. Comparing base (88e80fc) to head (e8a63c7).
⚠️ Report is 26 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit da7142b into infiniflow:main Aug 28, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants