Skip to content

test(feishu): add regression for audio download resource type=file#16311

Merged
Takhoffman merged 3 commits intoopenclaw:mainfrom
Yaxuan42:fix/feishu-audio-download-type-file
Feb 28, 2026
Merged

test(feishu): add regression for audio download resource type=file#16311
Takhoffman merged 3 commits intoopenclaw:mainfrom
Yaxuan42:fix/feishu-audio-download-type-file

Conversation

@Yaxuan42
Copy link
Contributor

@Yaxuan42 Yaxuan42 commented Feb 14, 2026

Summary

Adds a regression test ensuring Feishu audio message resource downloads use type=file (Feishu API only supports type=image|file).

Context

The runtime logic already maps non-image message types to type=file, but we had no test coverage to prevent re-introducing type=audio (which causes HTTP 400 per Feishu docs).

Changes

  • Add downloadMessageResourceFeishu test suite in extensions/feishu/src/media.test.ts
    • audio uses type=file
    • image uses type=image

Fixes #8746

Test plan

  • npx vitest run extensions/feishu/src/media.test.ts
  • pnpm lint

Greptile Summary

Adds a test suite for downloadMessageResourceFeishu in the Feishu extension, with two test cases verifying that the function correctly forwards type=file for audio resources and type=image for image resources to the Feishu SDK.

Confidence Score: 4/5

  • This PR is safe to merge — it only adds test code with no production changes.
  • Pure test addition with no production code changes. The tests are correct in what they verify (parameter forwarding), though the "audio uses type=file" test doesn't cover the actual mapping logic in bot.ts that prevents the Feishu/Lark: audio resource download uses unsupported type=audio (should use type=file) #8746 regression. No risk to existing behavior.
  • No files require special attention

Last reviewed commit: 05ca5a2

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +216 to +229
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);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 22, 2026
@Yaxuan42 Yaxuan42 closed this Feb 28, 2026
@Yaxuan42
Copy link
Contributor Author

superseded by main behavior, re-opening as test-only follow-up

@Takhoffman Takhoffman reopened this Feb 28, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

Adds comprehensive regression test coverage for Feishu audio message downloads, ensuring they use type=file instead of type=audio (which causes HTTP 400). Successfully addresses previous review feedback by extracting the mapping logic into a testable toMessageResourceType function.

  • Extracted toMessageResourceType function from inline logic, making the audio→file mapping explicit and testable
  • Added unit tests in bot.test.ts covering all mapping cases (image→image, audio→file, other types→file)
  • Added integration tests in media.test.ts verifying parameter forwarding to Feishu API
  • Clear documentation explaining Feishu API constraint (supports only type=image|file)

Confidence Score: 5/5

  • Safe to merge - pure test addition with minimal refactoring, no production behavior changes
  • Score reflects comprehensive test coverage of the regression risk, clean extraction of mapping logic into a testable function, and clear documentation. The changes are additive (tests + refactoring existing inline logic), with no behavioral modifications to production code paths.
  • No files require special attention

Last reviewed commit: e704739

@Takhoffman Takhoffman force-pushed the fix/feishu-audio-download-type-file branch from e704739 to c73174d Compare February 28, 2026 04:46
Yaxuan42 and others added 3 commits February 27, 2026 22:48
…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
@Takhoffman Takhoffman force-pushed the fix/feishu-audio-download-type-file branch from c73174d to 63c3715 Compare February 28, 2026 04:49
@Takhoffman Takhoffman merged commit 8beb048 into openclaw:main Feb 28, 2026
3 checks passed
@Takhoffman
Copy link
Contributor

PR #16311 - test(feishu): add regression for audio download resource type=file (#16311)

Merged via squash.

  • Merge commit: 8beb048
  • 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
  • Changes made:
  • CHANGELOG.md\n- extensions/feishu/src/bot.ts\n- extensions/feishu/src/bot.test.ts\n- extensions/feishu/src/media.test.ts
  • Why these changes were made:
  • Rebased onto current main and resolved changelog conflict after fix(feishu): insert document blocks sequentially to preserve order (#26022) #26172 merge.\n- Added changelog entry required by merge policy.\n- Preserved and validated audio/file resource-type regression coverage at the call site.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Thanks @Yaxuan42!

@Yaxuan42 Yaxuan42 deleted the fix/feishu-audio-download-type-file branch February 28, 2026 05:15
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
…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>
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 28, 2026
…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>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…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>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…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)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…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)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
…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)
vincentkoc pushed a commit to Sid-Qin/openclaw that referenced this pull request Feb 28, 2026
…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>
vincentkoc pushed a commit to rylena/rylen-openclaw that referenced this pull request Feb 28, 2026
…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>
newtontech pushed a commit to newtontech/openclaw-fork that referenced this pull request Feb 28, 2026
…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>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
…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>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Mar 1, 2026
…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>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
…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
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
…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>
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…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>
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
…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>
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…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>
venjiang pushed a commit to venjiang/openclaw that referenced this pull request Mar 2, 2026
…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>
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
…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>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…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>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
…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
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
…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>
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
…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>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…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>
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu/Lark: audio resource download uses unsupported type=audio (should use type=file)

3 participants