{"record":{"id":"8c1894359875bb5b","repo":"xpzouying/xiaohongshu-mcp","slug":"error-8c1894","errorCode":null,"errorMessage":"页面没有文件上传输入框","messagePattern":"页面没有文件上传输入框","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":283,"sourceCode":"\t\t}\n\t\ttime.Sleep(1 * time.Second)\n\t}\n\n\treturn nil\n}\n\n// findImageUploadInput 查找图片上传的输入框\nfunc findImageUploadInput(page *rod.Page, first bool) (*rod.Element, error) {\n\tif first {\n\t\treturn page.Element(\".upload-input\")\n\t}\n\n\tinputs, err := page.Elements(`input[type=\"file\"]`)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(inputs) == 0 {\n\t\treturn nil, errors.New(\"页面没有文件上传输入框\")\n\t}\n\n\tfor _, input := range inputs {\n\t\taccept, err := input.Attribute(\"accept\")\n\t\tif err != nil || accept == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif acceptsImage(*accept) {\n\t\t\treturn input, nil\n\t\t}\n\t}\n\n\treturn inputs[0], nil\n}\n\n// acceptsImage 判断 accept 属性是否接受图片\nfunc acceptsImage(accept string) bool {\n\taccept = strings.ToLower(accept)","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L265-L301","documentation":"This error is thrown by findImageUploadInput when the Xiaohongshu publish page DOM contains no `input[type=\"file\"]` elements. The library relies on a native file input to call rod's SetFiles for image uploads; without such an input it cannot proceed. It typically means the page did not load into the expected upload state or XHS changed its upload widget markup.","triggerScenarios":"uploadImages calls findImageUploadInput for the 2nd..Nth image (first image uses `.upload-input`); the selector `input[type=\"file\"]` matches zero elements — e.g. page still loading, previous upload navigated away, or the DOM was re-rendered removing the hidden input.","commonSituations":"Slow network leaving the publish page half-rendered; XHS frontend update that lazy-creates the file input only after a click; calling uploadImages after the page already navigated; a modal/overlay replacing the upload area mid-loop.","solutions":["Verify the browser is still on the image publish page (URL contains /publish/publish) before calling uploadImages","Increase wait for the page/upload widget to render before the first upload (wait for `.upload-input` or the upload area to appear)","Check if Xiaohongshu changed the DOM; update the `input[type=\"file\"]` selector in findImageUploadInput accordingly","Retry uploadImages; transient rendering races often resolve on a second run"],"exampleFix":"// before\nif len(inputs) == 0 {\n\treturn nil, errors.New(\"页面没有文件上传输入框\")\n}\n// after\nif len(inputs) == 0 {\n\t// wait briefly for lazy-rendered input\n\t_ = page.WaitElementsMoreThan(`input[type=\"file\"]`, 0, 5*time.Second) // or fallback to .upload-input\n}","handlingStrategy":"retry","validationCode":"func hasFileInput(page *rod.Page) bool {\n\tinputs, err := page.Elements(`input[type=\"file\"]`)\n\treturn err == nil && len(inputs) > 0\n}","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n\tif err := uploadImages(page, paths); err == nil {\n\t\tbreak\n\t} else if strings.Contains(err.Error(), \"页面没有文件上传输入框\") {\n\t\ttime.Sleep(3 * time.Second) // 等页面渲染后重试\n\t\tcontinue\n\t}\n\treturn err\n}","preventionTips":["Before uploading, wait for the upload widget (.upload-input) to be visible","Confirm the page URL is still the publish page before each image upload step","Re-check XHS DOM selectors after frontend updates"],"tags":["dom","file-upload","selector","xiaohongshu"],"backgroundTag":"file-input-not-found","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}