CodexBridge icon indicating copy to clipboard operation
CodexBridge copied to clipboard

Weixin login QR can save HTML as .png when qrcode_img_content is a URL

Open yourskenny opened this issue 7 months ago • 1 comments

## 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:login printed a file: ...png path.
  • 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 qrcode token showed just a string.
  • Scanning a QR generated from the full liteapp.weixin.qq.com URL 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.json and package-lock.json appeared out of sync, causing npm ci to fail because express and hono were missing from the lockfile.
  • ffmpeg-static install failed with UNABLE_TO_VERIFY_LEAF_SIGNATURE until Node/npm used the Windows system CA store.
  • The symlink escape test can fail on Windows with EPERM when 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 /status and /helps from 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.

yourskenny avatar Apr 29 '26 16:04 yourskenny

Thanks for the detailed report. I reproduced the main issue and fixed that path.

What was happening:

  • when qrcode_img_content was an https://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 .png path

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-latest and windows-latest
  • PR: #11

About the two extra Windows notes in this issue:

  • ffmpeg-static certificate-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.

Gan-Xing avatar May 02 '26 00:05 Gan-Xing