fix(platform): reject duplicate platform IDs at load time - #9773
Open
weed33834 wants to merge 1 commit into
Open
fix(platform): reject duplicate platform IDs at load time#9773weed33834 wants to merge 1 commit into
weed33834 wants to merge 1 commit into
Conversation
Proactive messages are routed by platform ID and pick the first matching adapter instance. When legacy configs contain two adapters with the same ID, every proactive send silently goes through the first adapter, i.e. the wrong QQ account (AstrBotDevs#9742). Creation-time validation was added in the FastAPI migration, but configs created before it still load without any complaint. Skip duplicate-ID adapters at load time with a loud error so the ID to account mapping stays unique.
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.
Motivation
Fixes #9742. Proactive messages (cron jobs, send_message_to_user, etc.) are routed by platform ID and pick the first matching adapter instance. When a config contains two adapters with the same ID, every proactive send silently goes through the first adapter, i.e. the wrong QQ account.
BotConfigService.create_bot already rejects duplicate IDs at creation time (added in the FastAPI migration), but configs created before that change still load without any complaint and keep misrouting forever.
Modifications
No breaking changes. No new dependencies.
Test Results
ext $ uvx --from ruff==0.15.22 ruff format --check . 501 files already formatted $ uvx --from ruff==0.15.22 ruff check . All checks passed! $ TESTING=true python -m pytest tests/unit/test_platform_duplicate_id.py tests/unit/test_core_lifecycle.py -q 29 passed $ python scripts/smoke_startup_check.py Smoke test passedFull suite failure set is identical to a clean upstream master checkout; zero failures in touched modules.
Summary by Sourcery
Prevent duplicate platform IDs from being loaded so platform-based message routing remains unambiguous.
Bug Fixes:
Tests: