{"record":{"id":"4c1569dc44bd5659","repo":"siyuan-note/siyuan","slug":"open-form-part-s-file-s-error-s","errorCode":null,"errorMessage":"open form part [%s] file [%s] error: %s","messagePattern":"open form part \\[(.+?)\\] file \\[(.+?)\\] error: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/server.go","lineNumber":327,"sourceCode":"\t} else if multipartForm != nil {\n\t\t// multipart/form-data\n\t\tform = &RequestForm{\n\t\t\tValue: multipartForm.Value,\n\t\t\tFile:  make(map[string][]*RequestFile),\n\t\t}\n\n\t\tfor partName, fileHandlers := range multipartForm.File {\n\t\t\tfiles := make([]*RequestFile, len(fileHandlers))\n\t\t\tform.File[partName] = files\n\t\t\tfor i, handler := range fileHandlers {\n\t\t\t\tfiles[i] = &RequestFile{\n\t\t\t\t\tFilename: handler.Filename,\n\t\t\t\t\tHeaders:  handler.Header,\n\t\t\t\t\tSize:     handler.Size,\n\t\t\t\t}\n\t\t\t\tfile, openErr := handler.Open()\n\t\t\t\tif openErr != nil {\n\t\t\t\t\terr = fmt.Errorf(\"open form part [%s] file [%s] error: %s\", partName, handler.Filename, openErr.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tcontent := make([]byte, handler.Size)\n\t\t\t\tn, readErr := file.Read(content)\n\t\t\t\tfile.Close()\n\t\t\t\tif readErr != nil {\n\t\t\t\t\terr = fmt.Errorf(\"read form part [%s] file [%s] error: %s\", partName, handler.Filename, readErr.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfileData := content[:n]\n\t\t\t\tfiles[i].Data = &fileData\n\t\t\t}\n\t\t}\n\t} else if len(c.Request.PostForm) > 0 {\n\t\t// application/x-www-form-urlencoded\n\t\tform = &RequestForm{\n\t\t\tValue: c.Request.PostForm,\n\t\t\tFile:  nil,","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/plugin/server.go#L309-L345","documentation":"When parsing a multipart form upload, the plugin server opens each file part via handler.Open(); if opening the uploaded file fails (disk/temp-file error), the error is wrapped with the part name and client-provided filename and returned to the caller.","triggerScenarios":"Uploading a file through the plugin server's multipart endpoint when the server cannot open the multipart part's underlying temp file - e.g. OS temp directory issues, too many open files, or corrupted multipart encoding.","commonSituations":"Server host with a full or unwritable temp directory, EMFILE (too many open files) under heavy concurrent uploads, or a client sending malformed multipart bodies.","solutions":["Check the error suffix (%s) for the underlying cause and fix it (free disk space, raise ulimit -n)","Retry the upload; transient EMFILE usually resolves after load drops","Ensure the client sends well-formed multipart/form-data with valid file parts"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { await uploadFile(form); } catch (e) { if (String(e).includes('open form part')) { await sleep(1000); await uploadFile(form); } else { throw e; } }","preventionTips":["Ensure the server temp directory exists, is writable, and has free space","Raise the open-file limit for high-concurrency upload workloads","Send standards-compliant multipart/form-data from clients"],"tags":["http","multipart","file-upload"],"backgroundTag":"file-open-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}