惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
I
InfoQ
V
Visual Studio Blog
罗磊的独立博客
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Jina AI
Jina AI
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
The Cloudflare Blog
小众软件
小众软件
雷峰网
雷峰网
V
V2EX
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(feishu): fallback to media resource download (#73986)...
steipete · 2026-04-30 · via Recent Commits to openclaw:main

@@ -639,6 +639,12 @@ describe("sanitizeFileNameForUpload", () => {

639639

});

640640641641

describe("downloadMessageResourceFeishu", () => {

642+

function httpStatusError(status: number): Error & { response: { status: number } } {

643+

return Object.assign(new Error(`Request failed with status code ${status}`), {

644+

response: { status },

645+

});

646+

}

647+642648

beforeEach(() => {

643649

vi.clearAllMocks();

644650

mockResolvedFeishuAccount();

@@ -717,6 +723,97 @@ describe("downloadMessageResourceFeishu", () => {

717723

});

718724

});

719725726+

it("retries file resources as media after HTTP 502", async () => {

727+

const originalError = httpStatusError(502);

728+

messageResourceGetMock.mockRejectedValueOnce(originalError).mockResolvedValueOnce({

729+

data: Buffer.from("fake-ios-video-data"),

730+

headers: {

731+

"content-type": "video/mp4",

732+

"content-disposition": `attachment; filename="ios-video.mp4"`,

733+

},

734+

});

735+736+

const result = await downloadMessageResourceFeishu({

737+

cfg: emptyConfig,

738+

messageId: "om_ios_video_msg",

739+

fileKey: "file_key_ios_video",

740+

type: "file",

741+

});

742+743+

expect(messageResourceGetMock).toHaveBeenNthCalledWith(

744+

1,

745+

expect.objectContaining({

746+

path: { message_id: "om_ios_video_msg", file_key: "file_key_ios_video" },

747+

params: { type: "file" },

748+

}),

749+

);

750+

expect(messageResourceGetMock).toHaveBeenNthCalledWith(

751+

2,

752+

expect.objectContaining({

753+

path: { message_id: "om_ios_video_msg", file_key: "file_key_ios_video" },

754+

params: { type: "media" },

755+

}),

756+

);

757+

expect(result).toMatchObject({

758+

buffer: Buffer.from("fake-ios-video-data"),

759+

contentType: "video/mp4",

760+

fileName: "ios-video.mp4",

761+

});

762+

});

763+764+

it("rethrows the original HTTP 502 when the media retry fails", async () => {

765+

const originalError = httpStatusError(502);

766+

messageResourceGetMock

767+

.mockRejectedValueOnce(originalError)

768+

.mockRejectedValueOnce(new Error("media retry failed"));

769+770+

await expect(

771+

downloadMessageResourceFeishu({

772+

cfg: emptyConfig,

773+

messageId: "om_ios_video_msg",

774+

fileKey: "file_key_ios_video",

775+

type: "file",

776+

}),

777+

).rejects.toBe(originalError);

778+779+

expect(messageResourceGetMock).toHaveBeenNthCalledWith(

780+

1,

781+

expect.objectContaining({ params: { type: "file" } }),

782+

);

783+

expect(messageResourceGetMock).toHaveBeenNthCalledWith(

784+

2,

785+

expect.objectContaining({ params: { type: "media" } }),

786+

);

787+

});

788+789+

it("does not retry non-fallback download failures", async () => {

790+

for (const scenario of [

791+

{ messageId: "om_image_msg", fileKey: "img_key_502", type: "image" as const, status: 502 },

792+

{ messageId: "om_file_msg", fileKey: "file_key_500", type: "file" as const, status: 500 },

793+

]) {

794+

const originalError = httpStatusError(scenario.status);

795+

messageResourceGetMock.mockClear();

796+

messageResourceGetMock.mockRejectedValueOnce(originalError);

797+798+

await expect(

799+

downloadMessageResourceFeishu({

800+

cfg: emptyConfig,

801+

messageId: scenario.messageId,

802+

fileKey: scenario.fileKey,

803+

type: scenario.type,

804+

}),

805+

).rejects.toBe(originalError);

806+807+

expect(messageResourceGetMock).toHaveBeenCalledTimes(1);

808+

expect(messageResourceGetMock).toHaveBeenCalledWith(

809+

expect.objectContaining({

810+

path: { message_id: scenario.messageId, file_key: scenario.fileKey },

811+

params: { type: scenario.type },

812+

}),

813+

);

814+

}

815+

});

816+720817

it("recovers CJK filenames from plain Content-Disposition headers decoded as Latin-1", async () => {

721818

const fileName = "武汉15座山登山信息汇总.csv";

722819

const latin1HeaderFileName = Buffer.from(fileName, "utf8").toString("latin1");