# QR Code Import Conflict — Root Cause Analysis

## Problem

QR code generation via `GET /api/v1/wx/auth/qr/code` succeeds (HTTP 200) but the image file `static/wx_qrcode.png` is never created. The QR status endpoint always returns `qr_code: false`.

## Root Cause

`apis/auth.py` imports WX_API twice, with the second import shadowing the first:

```python
# Line 22 — HTTP-based version (uses requests, no browser)
from driver.base import WX_API

# Line 30 — Playwright-based version (OVERRIDES line 22)
from driver.wx import WX_API
```

The Playwright-based `WX_API.GetCode()` launches a headless browser in a thread to navigate WeChat's login page and extract the QR code image. On servers without webkit installed (China GFW blocks Playwright browser downloads), this silently fails with:

```
BrowserType.launch: Executable doesn't exist at .../webkit-*/pw_run.sh
```

The HTTP-based version (`driver.wx_api.WeChatAPI.get_qr_code()`) uses direct `requests` calls to WeChat's API endpoints and works reliably without any browser.

## Diagnosis Steps

1. Check if QR image was created: `ls -la ~/project/we-mp-rss-main/static/wx_qrcode.png`
2. Check logs for browser errors: `journalctl -u we-mp-rss | grep -i "webkit\|pw_run\|BrowserType"`
3. If "Executable doesn't exist at .../webkit" appears → import conflict confirmed
4. Verify: `grep "import.*WX_API" ~/project/we-mp-rss-main/apis/auth.py` — should NOT show `from driver.wx import WX_API`

## Fix

```python
# REMOVE line 30:
from driver.wx import WX_API

# ADD:
WX_API = __import__('driver.wx_api', fromlist=['WeChat_api']).WeChat_api
```

## Verification

After fix + restart:
```bash
curl -s http://localhost:8001/api/v1/wx/auth/qr/status -H "Authorization: Bearer $TOKEN"
# Should return {"data": {"qr_code": true}} within 1 second
```
