From 9bf7da64b67b46c1e746e6a315bae4aaafa953e0 Mon Sep 17 00:00:00 2001 From: sirius7988 Date: Sat, 21 Mar 2026 13:55:27 +0800 Subject: [PATCH] fix(feishu): extractPermissionError also recognizes code 99991401 Previously extractPermissionError() only checked for error code 99991672, silently swallowing other Feishu permission error codes like 99991401. This caused resolveFeishuSenderName() to return {} instead of surfacing permission errors when the Feishu contact API returned 99991401. Now also checks for: - 99991401 (scope not granted) - 99991672 (permission denied) - Any non-zero code with 'permission' in the error message Fixes a bug where permission errors were silently ignored in sender name resolution. --- extensions/feishu/src/bot-sender-name.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/feishu/src/bot-sender-name.ts b/extensions/feishu/src/bot-sender-name.ts index 57b5aad3c96..20b780d6fa3 100644 --- a/extensions/feishu/src/bot-sender-name.ts +++ b/extensions/feishu/src/bot-sender-name.ts @@ -43,7 +43,12 @@ function extractPermissionError(err: unknown): FeishuPermissionError | null { return null; } const feishuErr = data as { code?: number; msg?: string }; - if (feishuErr.code !== 99991672) { + // Feishu permission/scope error codes: 99991401 (scope not granted) and 99991672 (permission denied) + const isPermissionError = + feishuErr.code === 99991672 || + feishuErr.code === 99991401 || + (feishuErr.code !== 0 && typeof feishuErr.code === "number" && feishuErr.msg?.toLowerCase().includes("permission")); + if (!isPermissionError) { return null; } const msg = feishuErr.msg ?? "";