mirror of
https://github.com/THU-MAIC/OpenMAIC.git
synced 2026-10-12 04:39:39 +08:00
#1514 moved every lib/audio provider call to the npm undici package's fetch so the pinned dispatcher is guaranteed to be honored. But the adapters kept building multipart bodies with the platform-global FormData — a class of Node's bundled undici — and undici's serializer brand-checks a FormData body against its own class. A foreign FormData fell through to the string branch and left the process as `content-type: text/plain;charset=UTF-8` with the 17-byte literal `[object FormData]` as the whole body: the audio bytes and every field (including `model`) were dropped, downstream gateways fell back to whisper-1 and answered 503, and every multipart audio request (ASR, TTS FormData paths, voice registration/cloning) failed with a generic internal error. Bare Blob/File, string/JSON/Buffer and stream bodies were never affected: undici 7.29.0 exports no File/Blob classes of its own and its bare-body brand checks (and multipart part handling) bind the platform classes. Normalize the body in the transport, once, before either transport path serializes it, so the adapters can keep the platform globals as their public API boundary: a foreign FormData is re-created as undici's own with every entry carried over verbatim — `append` (not `set`) so repeated field names survive, and no filename argument so a platform File part keeps its own name/type/lastModified. Everything else passes through untouched. Also drive real loopback regression tests with a platform-global FormData (direct, with repeated field names, empty, and across a 307 redirect hop whose per-hop loop re-issues the normalized body) and a bare Blob, asserting multipart on the wire instead of `[object FormData]`, and update the voxcpm unit test that asserted the buggy contract (a platform FormData at the undici boundary). Fixes #1579 Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>