fix(feishu): check response.ok before calling response.json() in streaming card (#35628)

Merged via squash.

Prepared head SHA: 62c3fec80d
Co-authored-by: Sid-Qin <201593046+Sid-Qin@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
Sid
2026-03-05 17:58:21 +08:00
committed by GitHub
parent c522154771
commit 06ff25cce4
2 changed files with 9 additions and 0 deletions

View File

@@ -67,6 +67,10 @@ async function getToken(creds: Credentials): Promise<string> {
policy: { allowedHostnames: resolveAllowedHostnames(creds.domain) },
auditContext: "feishu.streaming-card.token",
});
if (!response.ok) {
await release();
throw new Error(`Token request failed with HTTP ${response.status}`);
}
const data = (await response.json()) as {
code: number;
msg: string;
@@ -198,6 +202,10 @@ export class FeishuStreamingSession {
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
auditContext: "feishu.streaming-card.create",
});
if (!createRes.ok) {
await releaseCreate();
throw new Error(`Create card request failed with HTTP ${createRes.status}`);
}
const createData = (await createRes.json()) as {
code: number;
msg: string;