fix(feishu): include audio duration in uploads - #8631
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused Feishu regression coverage. The underlying gap remains on current main: plugins/platforms/feishu/adapter.py:4559-4563 builds audio upload bodies without duration, and tests/gateway/test_feishu.py:2527-2575 has no duration assertion.
Problems
- The diff targets
gateway/platforms/feishu.py, but current main relocated that adapter toplugins/platforms/feishu/adapter.pyin552adbe0827c32df8ed9bb19e908c26eff43add7; the PR is currentlyDIRTY. - The added probe performs WAV reads and potentially
subprocess.run()synchronously inside the async upload path. Current adapter SDK work uses_run_blockingatplugins/platforms/feishu/adapter.py:1692-1695. - The added
ffprobecall has no timeout.
Suggested changes
- Port the change and tests to the plugin adapter/current test imports.
- Execute the probe through the adapter executor and give
ffprobea finite timeout while preserving the best-effort fallback.
Automated hermes-sweeper review.
| ) | ||
| try: | ||
| duration_ms: Optional[int] = None | ||
| if resolved_message_type == "audio": |
There was a problem hiding this comment.
_probe_audio_duration_ms() can read files and launch ffprobe; this async upload path should await executor-backed work (for example the adapter's _run_blocking) rather than run the probe on the event loop.
| return max(1, int(duration_ms)) | ||
| except Exception: | ||
| pass | ||
|
|
There was a problem hiding this comment.
Please give this ffprobe invocation a finite timeout. Without one, a hung executable can indefinitely delay outbound voice delivery.
|
Closing as stale target: this PR patches Feishu upload duration is being salvaged via #40592 against the live plugin adapter — and credit where due: this PR was the earliest report/fix of the missing-duration problem. Thanks @sgaofen — if anything in your change isn't covered by the salvage noted above, please resubmit against the current plugin adapter. |
Summary
ffprobeormutagenwhen availableRoot Cause
send_voice()reused the generic Feishu file-upload path, but the upload body never included audio duration metadata. Feishu's native audio message rendering depends on that field, so successful uploads could still display with missing or incorrect duration.Closes #8300.
Validation
python3 -m py_compile gateway/platforms/feishu.py tests/gateway/test_feishu.pyuv run --extra dev pytest tests/gateway/test_feishu.py -q -k 'send_voice_uploads_opus_and_sends_audio_message or probe_audio_duration_uses_wav_header'uv run --extra dev pytest tests/gateway/test_feishu.py -q -k 'not test_build_event_handler_registers_reaction_and_card_processors'Platform Tested
Contribution Guide Notes
CONTRIBUTING.mdand checked for existing open PRs before submitting this scoped change.pytest tests/ -qpass unless explicitly noted.