Repository navigation
fix(task): build text-only multipart requests from JSON - #8198
Conversation
|
No actionable comments were generated in the recent review. WalkthroughThe task adaptor stores the generated multipart content type on the submit descriptor. It delays parsing the client form until a multipart part references an uploaded file. Tests cover multipart output from JSON input and the missing-upload error. ChangesTask plugin multipart request building
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk:
|
Agent
Links
User request
Out of scope — refuse
Open gate — do not open unless all are satisfied
go buildor tests passed: yes,见修复前后复现及输出字段验证。Kind
Issue facts
multipart boundary not found;实际 API 显示 HTTP 500 /build_request_failed。ba5f736的确定性本地复现执行一次、失败一次。m、非透传。计费/UI/部署不适用;详见 bug(task): JSON input fails when a plugin builds text-only multipart #8197。Change
BuildRequestBody仅在遇到parts[].fileRef时解析原始 multipart 表单,解析一次并保留清理逻辑。没有文件引用的描述符直接编码文本字段并生成输出 boundary。Research
Duplicate / prior art
repo:QuantumNous/new-api "multipart boundary"、repo:QuantumNous/new-api multipart JSON task plugin、repo:QuantumNous/new-api "BuildRequestBody" "multipart"。Docs and code
/en/docs/guide/console/channel-management,配置覆盖不能解决输入格式被误判的问题。docs/plugin-api/v1.md的 Request body、Request building;输入 body kind 与输出描述符独立。adaptor.go原来无条件调用common.ParseMultipartFormReusable;common/gin.go从客户端 Content-Type 提取 boundary;relay_task.go在发送前返回构造错误。Alternatives considered
Files
relay/channel/task/jsplugin/adaptor.gorelay/channel/task/jsplugin/adaptor_test.goBehavior
Verification
go test ./relay/channel/task/jsplugin -run '^TestTaskAdaptorBuildsMultipartFromJSON$' -count=1 -v:只加测试、未修复时,text_fields返回multipart boundary not found。go test ./relay/channel/task/jsplugin -run '^TestTaskAdaptor(BuildsMultipartFromJSON|BuildsMultipartFromOpaqueFileReference|DoesNotEmitInjectedMultipartDispositionHeaders)$' -count=1 -v:修复后通过;HTTP 解析器读取到 model、prompt、重复 tag 和空字段;缺少上传的文件引用仍拒绝;已有文件内容转发及 header 注入防护通过。go test ./relay/channel/task/jsplugin ./pkg/jsplugin ./common -count=1:三个包分别ok(2.305s、0.573s、1.310s)。首轮因沙箱禁止本地端口监听中断,允许本机模拟服务后通过。go vet ./relay/channel/task/jsplugin ./pkg/jsplugin ./common:退出0,无诊断。git diff --check:退出0;修改文件已 gofmt。ba5f736与用户合并后的 fork;涉及的两个文件相同。未发送真实生成请求。Risks
Scope check
Summary by CodeRabbit