{{ message }}
Repository navigation
fix(linkai): reply when the midjourney image index is not a number - #3291
Merged
zhayujie merged 1 commit intoSep 29, 2026
Merged
Conversation
$mju/$mjv parse the image index with a bare int(), so a token like "2x" raises ValueError out of on_handle_context. The worker's callback only logs it, so the command produces no reply at all, while the two neighbouring mistakes on the same argument (missing, or numeric but outside 1..4) both answer. Also drop three f-strings without placeholders in the touched file: the lint job scans only files a PR changes, so inherited F-class debt turns that gate red.
Owner
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.

What does this PR do?
$mju/$mjvparse the image index with a bareint()(plugins/linkai/midjourney.py:161). The two mistakes around that argument the code already anticipates -- one missing (命令缺少参数, line 158) and a number outside 1..4 (图片序号 N 错误, line 163) -- both answer the user, but a token that is not a number at all raisesValueErrorout ofprocess_mj_task. It escapeson_handle_contextintoChatChannel._fail_callback(channel/chat_channel.py:452-453), which only logs:So
$mju 11055927171882 2xproduces no message of any kind -- not an error, not a hint about the expected shape. Copying an index out of a UI or typing2xis an ordinary slip.This PR guards the parse and replies through the same
_set_reply_textpath the neighbouring guards use, so the failure is visible to the user:The three
fprefixes removed elsewhere in the file carry no placeholders. The lint job runsruff check --select Fover the files a PR touches, so that inherited F-class debt in the same file would otherwise turn this PR's gate red.Type of change
Tests
tests/test_linkai_midjourney_index_argument.pydrivesprocess_mj_task(TaskType.UPSCALE, ...)through anEventContext, the way the existingtests/test_linkai_midjourney_send.pyandtests/test_keyword_attachment_urls.pydo, and asserts both that a non-numeric token now gets a reply and that the existing 1..4 message still fires for9.c7ae3ba5:1 failed, 1 passed--ValueError: invalid literal for int() with base 10: '2x'atplugins/linkai/midjourney.py:161.2 passed.pytest tests/ -q: 38 failed, 2216 passed on this branch vs 38 failed, 2214 passed on plainc7ae3ba5-- same failures, +2 from the new file.ruff check plugins/linkai/midjourney.py tests/test_linkai_midjourney_index_argument.py --select F --ignore F403,F405: All checks passed.Checklist