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.
This commit is contained in:
sirius7988 2026-03-21 13:55:27 +08:00
parent 8a05c05596
commit 9bf7da64b6

View File

@ -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 ?? "";