fix: resolve each OneBot file segment by its own ID - #10098
Open
xiongyuyang wants to merge 1 commit into
Open
xiongyuyang wants to merge 1 commit into
xiongyuyang wants to merge 1 commit into
Conversation
kilisamemarisaaa
approved these changes
Sep 16, 2026
kilisamemarisaaa
left a comment
There was a problem hiding this comment.
Reviewed at head 42b0afa. The converter now uses each current file segment's file_id for both group and private OneBot actions, so leading text no longer shifts lookup and multiple attachments no longer reuse the first ID. In a Windows/Python 3.12 tarball checkout of this exact head, the author's focused suite passed 19 tests (4 pre-existing warnings); Ruff passed. The regression matrix covers group/private messages, leading text, and two distinct file attachments with mocked API responses. No correctness blocker found.
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.
Modifications
The OneBot message converter reads the first message segment's file ID when resolving every NapCat attachment. A leading text segment therefore causes attachments to be skipped with KeyError; multiple file segments repeatedly resolve the first file.
Read the current file segment's ID for both group and private messages. Add regression coverage for two attachments with and without leading text in each message type.
Screenshots or Test Results
Verification:
python -m pytest tests/unit/test_aiocqhttp_files.py tests/unit/test_aiocqhttp_reply.py tests/unit/test_aiocqhttp_poke.py tests/unit/test_aiocqhttp_group_info.py -q -p no:cacheproviderBefore the fix: all four new regression cases failed (repeated first ID or no URL resolution).
After the fix: 19 passed, 1 existing audioop deprecation warning on Windows/Python 3.12.
Ruff check and commit hooks passed. Tests exercise the real message converter with mocked OneBot API responses; no live QQ integration was run.
Checklist
Summary by Sourcery
Fix OneBot attachment URL resolution so every file segment is converted independently.
Bug Fixes:
Tests: