fix(channels/wechat): encode qrcode_img_content so the login QR is scannable#6086
Merged
Conversation
houko
enabled auto-merge (squash)
June 11, 2026 12:04
The WeChat sidecar's QR login encoded the iLink `qrcode` field into the dashboard QR canvas. But `qrcode` is only the opaque status-poll key — the payload the WeChat app decodes on scan is `qrcode_img_content`. Encoding the poll token makes WeChat render the QR as a plain-text string rather than a login prompt. The pre-migration in-process Rust adapter surfaced `qrcode_img_content` as the QR payload (the original #1560 / #1572 fix: "use iLink qr_url so WeChat can recognise the scan"). The sidecar migration (#5421) dropped that field and fell back to encoding the token, re-introducing the exact bug #1572 had fixed. `_qr_login` now reads `qrcode_img_content` and emits it as the `qr_ready` payload, falling back to the token with a WARN only if iLink omits the field; the `qrcode` token still drives status polling. Tests: updated the happy-path assertion to require `qrcode_img_content`, added a degraded-fallback case; full sdk/python suite 1874 passed.
Three tests that exercise different failure/edge paths all used a mock iLink response without `qrcode_img_content`, causing the fallback WARN introduced alongside the fix to fire spuriously on every run. Each affected test now uses a realistic response that matches the happy path, so the warning stays silent unless the field is genuinely absent.
houko
force-pushed
the
fix/wechat-qr-img-content
branch
from
June 11, 2026 12:13
dd6214f to
ed22529
Compare
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.
Symptom
Scanning the WeChat QR code shown in the dashboard does not log in — the WeChat app shows a meaningless string of characters instead of a login confirmation.
Root cause
iLink's
GET /ilink/bot/get_bot_qrcodereturns two relevant fields:qrcode— an opaque status-poll key, passed toget_qrcode_status?qrcode=…. It is not scannable.qrcode_img_content— the payload the WeChat app actually decodes on scan (what makes WeChat recognise it as a login).The pre-migration in-process Rust adapter surfaced
qrcode_img_contentas the QR payload — that was the explicit fix in #1560 / #1572 ("use iLink qr_url for WeChat QR code so WeChat can recognise the scan"). Its dashboard handler did:The WeChat → sidecar migration (#5421) dropped
qrcode_img_content._qr_loginread onlyqrcodeand encoded that opaque poll token into the QR, with a comment claiming "iLink does not surface a pre-formed deep-link URL." So the dashboard canvas encodes the poll key, WeChat can't recognise it as a login, and the user sees a plain string — re-introducing the exact bug #1572 had fixed.Fix
sdk/python/librefang/sidecar/adapters/wechat.py::_qr_login:qrcode_img_contentand emit it as theqr_readypayload (qr_code), which the dashboard encodes into the scannable canvas.qrcodetoken for status polling (get_qrcode_status).qrcode_img_content, fall back to the token with aWARN(degraded — renders something rather than crashing) instead of silently shipping an unscannable QR.qrcodestring is what operators scan.Tests
test_qr_login_emits_ready_then_confirmed_without_token_on_wireto provideqrcode_img_contentand assert theqr_readypayload is that value (not the token) — a regression guard tied to WeChat does not display QR codes #1560 / fix(dashboard): display WeChat QR code for iLink login #1572.test_qr_login_qr_payload_falls_back_to_token_when_img_content_absentcovering the degraded path (token fallback + WARN).sdk/pythonsuite: 1874 passed (local venv, pytest).Scope
Python sidecar only; independent of the other open channel PRs (#6085 describe-probe, #6083 goal-runner). No Rust changes.