Skip to content

Commit fc9380e

Browse files
fix(feishu): break loop on final-attempt fulfilled rate-limit body
ClawSweeper review on dc8d3be (P1, comment-shared.ts:166) caught a real bug: when the final retry attempt also fulfilled with a rate-limit body (e.g. { code: 11232, ... }), the guard `attempt < FEISHU_SEND_MAX_RETRIES` was false so control fell through to `return result` — bypassing the synthetic-error exhaustion path and handing the rate-limit body to the caller as if it were a successful response. The fulfilled-exhaustion test missed this because Vitest's local fs module cache served the pre-fix shape; running with a fresh cache reproduces the failure. Split the fulfilled-rate-limit branch so the body is always captured, then continue on a non-final attempt or break on the final attempt. Breaking falls through to the synthetic AxiosError-shaped throw below, which is exactly what the existing exhaustion test asserts.
1 parent dc8d3be commit fc9380e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

extensions/feishu/src/comment-shared.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,15 @@ export async function requestFeishuApi<T>(
159159
// Feishu SDK may fulfill with a rate-limit body (e.g. { code: 11232, ... })
160160
// instead of throwing. Classify before returning so retry covers both shapes.
161161
const fulfilledRateLimit = getFeishuSendRateLimitCodeFromResponse(result);
162-
if (fulfilledRateLimit !== undefined && attempt < FEISHU_SEND_MAX_RETRIES) {
162+
if (fulfilledRateLimit !== undefined) {
163+
// Capture for the synthetic-error path below; on a non-final attempt
164+
// continue retrying, on the final attempt fall through so the loop
165+
// exits and the wrapped exhaustion error is thrown.
163166
lastFulfilledRateLimit = { response: result, code: fulfilledRateLimit };
164-
continue;
167+
if (attempt < FEISHU_SEND_MAX_RETRIES) {
168+
continue;
169+
}
170+
break;
165171
}
166172
return result;
167173
} catch (error) {

0 commit comments

Comments
 (0)