test(feishu): add regression for audio download resource type=file#16311
Conversation
bfc1ccb to
f92900f
Compare
extensions/feishu/src/media.test.ts
Outdated
| it("audio uses type=file", async () => { | ||
| const result = await downloadMessageResourceFeishu({ | ||
| cfg: {} as any, | ||
| messageId: "om_audio_msg", | ||
| fileKey: "file_key_audio", | ||
| type: "file", | ||
| }); | ||
|
|
||
| expect(messageResourceGetMock).toHaveBeenCalledWith({ | ||
| path: { message_id: "om_audio_msg", file_key: "file_key_audio" }, | ||
| params: { type: "file" }, | ||
| }); | ||
| expect(result.buffer).toBeInstanceOf(Buffer); | ||
| }); |
There was a problem hiding this comment.
Test validates pass-through, not the actual mapping logic
This test passes type: "file" as input and asserts that type: "file" arrives at the mock — but downloadMessageResourceFeishu simply forwards whatever type it receives. The actual regression risk (audio → type=file mapping) lives in bot.ts:392:
const resourceType = messageType === "image" ? "image" : "file";As-is, this test would still pass even if someone changed that mapping to type: "audio" in bot.ts, because the mapping is not exercised here. For a true regression test for #8746, consider testing the call site in bot.ts (e.g. extractMediaFromMessage) where messageType === "audio" is mapped to resourceType = "file", or at minimum rename the test to clarify it's verifying the function's parameter forwarding contract.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/media.test.ts
Line: 216:229
Comment:
**Test validates pass-through, not the actual mapping logic**
This test passes `type: "file"` as input and asserts that `type: "file"` arrives at the mock — but `downloadMessageResourceFeishu` simply forwards whatever `type` it receives. The actual regression risk (audio → `type=file` mapping) lives in `bot.ts:392`:
```ts
const resourceType = messageType === "image" ? "image" : "file";
```
As-is, this test would still pass even if someone changed that mapping to `type: "audio"` in `bot.ts`, because the mapping is not exercised here. For a true regression test for #8746, consider testing the call site in `bot.ts` (e.g. `extractMediaFromMessage`) where `messageType === "audio"` is mapped to `resourceType = "file"`, or at minimum rename the test to clarify it's verifying the function's parameter forwarding contract.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Fixed in e704739. Added call-site mapping coverage by extracting and testing toMessageResourceType (audio -> file, image -> image, others -> file), and renamed the downloader test to clarify it verifies parameter forwarding only.
|
This pull request has been automatically marked as stale due to inactivity. |
|
superseded by main behavior, re-opening as test-only follow-up |
Greptile SummaryAdds comprehensive regression test coverage for Feishu audio message downloads, ensuring they use
Confidence Score: 5/5
Last reviewed commit: e704739 |
e704739 to
c73174d
Compare
…aw#8746) Feishu's messageResource.get API only supports type=image|file. Audio/video resources must use type=file, never type=audio. Add regression tests to prevent re-introduction of the unsupported type=audio parameter that causes HTTP 400 from the Feishu API. Fixes openclaw#8746 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- extract bot mapping helper toMessageResourceType and use it at messageResource call site\n- add unit tests for image/audio/video/file/sticker mapping\n- rename media test to clarify it validates parameter forwarding contract
c73174d to
63c3715
Compare
|
PR #16311 - test(feishu): add regression for audio download resource type=file (#16311) Merged via squash.
Thanks @Yaxuan42! |
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit e72df63)
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit e72df63)
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit e72df63)
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit 8beb048) # Conflicts: # CHANGELOG.md # extensions/feishu/src/bot.test.ts
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> (cherry picked from commit 8beb048) # Conflicts: # CHANGELOG.md # extensions/feishu/src/bot.test.ts
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
…penclaw#16311) thanks @Yaxuan42 Verified: - pnpm build - pnpm check - pnpm vitest run --config vitest.extensions.config.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/media.test.ts Co-authored-by: Yaxuan42 <184813557+Yaxuan42@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Summary
Adds a regression test ensuring Feishu audio message resource downloads use
type=file(Feishu API only supportstype=image|file).Context
The runtime logic already maps non-image message types to
type=file, but we had no test coverage to prevent re-introducingtype=audio(which causes HTTP 400 per Feishu docs).Changes
downloadMessageResourceFeishutest suite inextensions/feishu/src/media.test.tsFixes #8746
Test plan
npx vitest run extensions/feishu/src/media.test.tspnpm lintGreptile Summary
Adds a test suite for
downloadMessageResourceFeishuin the Feishu extension, with two test cases verifying that the function correctly forwardstype=filefor audio resources andtype=imagefor image resources to the Feishu SDK.bot.ts(extractMediaFromMessage), not indownloadMessageResourceFeishu— the test validates parameter forwarding but doesn't cover the mapping logic itselfConfidence Score: 4/5
Last reviewed commit: 05ca5a2