Skip to content

The agent that grows with you

fix(feishu): include app credentials in multiplex fingerprint (#76793)

webtecnica97b8a9786181
diff --git a/gateway/run.py b/gateway/run.py
index 730280f8385..5a438d25b96 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -17685,6 +17685,12 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew
# of a bot token. Including its secret keeps multiplexed profiles
# from spawning competing sidecars for the same account and port.
"_project_secret",
+ # Feishu/Lark authenticates with an app_id/app_secret pair rather
+ # than a single token (one active WebSocket connection per app).
+ # app_id is stable, log-safe, and already used as the adapter's
+ # _app_lock_identity, so including it lets the multiplex guard
+ # refuse cloned profiles competing for the same Feishu app.
+ "_app_id",
):
val = getattr(adapter, attr, None)
if isinstance(val, str) and val.strip():
diff --git a/tests/gateway/test_multiplex_adapter_registry.py b/tests/gateway/test_multiplex_adapter_registry.py
index 656a75c425e..859d56cdb21 100644
--- a/tests/gateway/test_multiplex_adapter_registry.py
+++ b/tests/gateway/test_multiplex_adapter_registry.py
@@ -39,6 +39,38 @@ class TestCredentialFingerprint:
assert fp1 is not None
assert "shared-project-secret" not in fp1
+ def test_reads_feishu_app_id(self):
+ """Feishu/Lark authenticates via app_id/app_secret, not a token.
+
+ Without _app_id in the fingerprint attribute list, every Feishu
+ adapter in a multiplexed gateway returns None here and the
+ same-credential conflict check is silently skipped — N profiles
+ spawn WebSocket clients against the same app, which evict each
+ other in a 1000 bye loop until all go offline.
+ """
+ class _FeishuAdapter:
+ def __init__(self):
+ self._app_id = "cli_a1b2c3"
+ self._app_secret = "top-secret"
+
+ fp1 = GatewayRunner._adapter_credential_fingerprint(_FeishuAdapter())
+ fp2 = GatewayRunner._adapter_credential_fingerprint(_FeishuAdapter())
+
+ assert fp1 is not None
+ assert fp1 == fp2 # same app -> same fingerprint -> conflict detected
+ assert "cli_a1b2c3" not in fp1 # log-safe, never the raw credential
+
+ def test_distinct_feishu_app_ids_distinct_fp(self):
+ class _FeishuAdapter:
+ def __init__(self, app_id):
+ self._app_id = app_id
+ self._app_secret = "s"
+
+ fp_a = GatewayRunner._adapter_credential_fingerprint(_FeishuAdapter("app-A"))
+ fp_b = GatewayRunner._adapter_credential_fingerprint(_FeishuAdapter("app-B"))
+
+ assert fp_a is not None and fp_b is not None
+ assert fp_a != fp_b
def test_reads_config_token(self):
"""Adapters like Discord store token on `config`, not on self.