From 08a5f4cbbbbf7ea2d992785310f63928e52ed0cf Mon Sep 17 00:00:00 2001 From: chengyongru Date: Thu, 18 Jun 2026 16:27:46 +0800 Subject: [PATCH] fix: keep feishu login URL unmodified maintainer edit: remove nonessential tracking parameters from the Feishu QR login URL after the author confirmed the flow works without them. --- nanobot/channels/feishu.py | 4 ---- tests/channels/test_feishu_login.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/nanobot/channels/feishu.py b/nanobot/channels/feishu.py index 375d856a..7faff617 100644 --- a/nanobot/channels/feishu.py +++ b/nanobot/channels/feishu.py @@ -364,10 +364,6 @@ def _begin_registration(domain: str = "feishu") -> dict: qr_url = res.get("verification_uri_complete", "") if not qr_url: raise RuntimeError("Feishu / Lark registration did not return a login URL") - if "?" in qr_url: - qr_url += "&from=nanobot&tp=nanobot" - else: - qr_url += "?from=nanobot&tp=nanobot" return { "device_code": device_code, "qr_url": qr_url, diff --git a/tests/channels/test_feishu_login.py b/tests/channels/test_feishu_login.py index 1f8685d4..fc057e67 100644 --- a/tests/channels/test_feishu_login.py +++ b/tests/channels/test_feishu_login.py @@ -47,6 +47,20 @@ def test_begin_registration_requires_login_url(monkeypatch): feishu_module._begin_registration() +def test_begin_registration_preserves_login_url(monkeypatch): + login_url = "https://accounts.feishu.cn/login?device_code=device" + monkeypatch.setattr( + feishu_module, + "_post_registration", + lambda _base_url, _body: { + "device_code": "device", + "verification_uri_complete": login_url, + }, + ) + + assert feishu_module._begin_registration()["qr_url"] == login_url + + def test_qr_register_returns_none_on_network_error(monkeypatch): def raise_connect_error(_base_url, _body): raise httpx.ConnectError("network down")