Weixin login QR can save HTML as .png when qrcode_img_content is a URL
## Summary
During local Windows testing, npm run weixin:login generated a QR artifact path ending in .png, but the file was actually an HTML document. Windows image viewers could not display it, so the Weixin login QR could not be scanned from the generated file.
The login eventually worked after rendering the full https://liteapp.weixin.qq.com/q/... URL itself as a QR code image.
What happened
The iLink API returned qrcode_img_content as a URL, for example:
https://liteapp.weixin.qq.com/q/...?qrcode=<token>&bot_type=3
The current materializeQrArtifact() flow treats HTTP(S) qrcode_img_content as a downloadable image URL. In my local run, fetching that URL returned HTML, but the body was saved to a .png path.
Result:
weixin:loginprinted afile: ...pngpath.- The file existed.
- The file header started with
<!doctype html>, not PNG bytes. - The image viewer showed that it could not display the image.
- Scanning a QR generated only from the raw
qrcodetoken showed just a string. - Scanning a QR generated from the full
liteapp.weixin.qq.comURL opened the expected Weixin ClawBot connection flow.
Suggested fix
When qrcode_img_content is an HTTP(S) URL, render that URL into a local QR PNG instead of downloading the URL target as if it were an image.
Keep the existing data:image/...;base64,... handling unchanged.
A regression test could assert that URL QR content produces a real PNG file, for example by checking the PNG magic bytes:
89 50 4E 47 0D 0A 1A 0A
Additional Windows notes from local validation
I also hit a few Windows-specific setup issues while getting the bridge running:
package.jsonandpackage-lock.jsonappeared out of sync, causingnpm cito fail becauseexpressandhonowere missing from the lockfile.ffmpeg-staticinstall failed withUNABLE_TO_VERIFY_LEAF_SIGNATUREuntil Node/npm used the Windows system CA store.- The symlink escape test can fail on Windows with
EPERMwhen symlink permission/developer mode is unavailable. It may be worth skipping that specific test when symlink creation is not permitted, while keeping the security behavior tested on platforms that support it.
Local validation
After rendering the URL QR locally, I was able to:
- complete
weixin:login - save the Weixin account token under the CodexBridge state directory
- start
weixin:serve - receive successful replies for
/statusand/helpsfrom Weixin ClawBot
Relevant local verification commands:
npm ci
npm run typecheck
npm run typecheck:js
npm test
On my Windows machine, the full test suite passed with one symlink-permission skip.
Thanks for the detailed report. I reproduced the main issue and fixed that path.
What was happening:
- when
qrcode_img_contentwas anhttps://liteapp.weixin.qq.com/q/...URL, the CLI treated it as an image download target - if that URL responded with HTML, the body could still be saved to a
.pngpath
What changed:
- URL-based QR content is now rendered into a local QR PNG directly, instead of downloading the URL target as if it were an image
- existing
data:image/...;base64,...handling stays unchanged - a regression test now checks that the URL branch produces a real PNG artifact
Validation:
- local repro no longer writes HTML into a
.png - GitHub Actions CI passed on both
ubuntu-latestandwindows-latest - PR: #11
About the two extra Windows notes in this issue:
ffmpeg-staticcertificate-chain failure (UNABLE_TO_VERIFY_LEAF_SIGNATURE)- symlink test
EPERM
I did not change those code paths in this fix. They also did not reproduce on the GitHub-hosted Windows runner, so I’m keeping this issue focused on the QR artifact bug. If either of those still reproduces on a local Windows machine, please open a separate issue with the exact Node/npm version, proxy/CA setup, and whether Developer Mode / symlink privileges are enabled.