{"record":{"id":"1234c47d924251a7","repo":"xpzouying/xiaohongshu-mcp","slug":"s-s-1234c4","errorCode":null,"errorMessage":"当前输入长度为%s，最大长度为%s","messagePattern":"当前输入长度为(.+?)，最大长度为(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":643,"sourceCode":"\t}\n\n\tcontentLength, err := elem.Text()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"获取正文长度文本失败\")\n\t}\n\n\treturn makeMaxLengthError(contentLength)\n}\n\nfunc makeMaxLengthError(elemText string) error {\n\tparts := strings.Split(elemText, \"/\")\n\tif len(parts) != 2 {\n\t\treturn errors.Errorf(\"长度超过限制: %s\", elemText)\n\t}\n\n\tcurrLen, maxLen := parts[0], parts[1]\n\n\treturn errors.Errorf(\"当前输入长度为%s，最大长度为%s\", currLen, maxLen)\n}\n\n// contentElemSelectors 正文输入框的候选选择器，按先后顺序尝试。\nvar contentElemSelectors = []string{\n\t`div[role=\"textbox\"][contenteditable=\"true\"]`,\n\t`div.tiptap[contenteditable=\"true\"]`,\n\t`div.ql-editor`,\n}\n\n// getContentElement 在 timeout 内轮询查找正文输入框，全部落空返回错误。\nfunc getContentElement(page *rod.Page, timeout time.Duration) (*rod.Element, error) {\n\tdeadline := time.Now().Add(timeout)\n\n\tfor {\n\t\telem, err := findContentElement(page)\n\t\tif err == nil {\n\t\t\treturn elem, nil\n\t\t}","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L625-L661","documentation":"This is the successfully-parsed over-length error from makeMaxLengthError: the page showed a title or content length-error indicator, its text matched the 'current/max' pattern, and the library reports the current input length versus the maximum allowed. It means the user's content or title exceeds Xiaohongshu's character limit and the publish cannot proceed.","triggerScenarios":"submitPublish calls checkTitleMaxLength / checkContentMaxLength after filling fields; the page displays the over-length badge (div.title-container div.max_suffix or div.edit-container div.length-error) whose text parses as '<currLen>/<maxLen>', producing this formatted error.","commonSituations":"Pasting long articles into the body editor; titles over ~20 characters; content with many emoji or multi-byte characters counted differently than expected; programmatically generated content exceeding the cap.","solutions":["Truncate the content to the reported max length before calling the publish API (the error tells you currLen and maxLen).","Shorten the title to fit the title limit.","Validate text length in your own code pre-publish (count runes the same way the site does).","If content is legitimately within limits but the badge appears, check for hidden characters or trailing whitespace."],"exampleFix":"// before\nerr := publisher.Publish(ctx, opts) // fails with 当前输入长度为1002，最大长度为1000\n// after\nif utf8.RuneCountInString(opts.Content) > 1000 {\n    opts.Content = string([]rune(opts.Content)[:1000])\n}\nerr := publisher.Publish(ctx, opts)","handlingStrategy":"validation","validationCode":"// enforce limits before calling the library\nconst maxTitle, maxContent = 20, 1000\nif utf8.RuneCountInString(title) > maxTitle {\n    return fmt.Errorf(\"标题超长: %d/%d\", utf8.RuneCountInString(title), maxTitle)\n}\nif utf8.RuneCountInString(content) > maxContent {\n    return fmt.Errorf(\"正文超长: %d/%d\", utf8.RuneCountInString(content), maxContent)\n}","typeGuard":"func withinLimit(s string, max int) bool {\n    return utf8.RuneCountInString(s) <= max\n}","tryCatchPattern":"err := publisher.Publish(ctx, opts)\nvar lenErr interface{ Error() string }\nif err != nil && strings.Contains(err.Error(), \"当前输入长度为\") {\n    // parse '当前输入长度为X，最大长度为Y' and truncate before retrying\n    return truncateAndRetry(opts, err.Error())\n}","preventionTips":["Truncate long inputs (by rune count, not bytes) before publishing","Count characters the way the site does (runes/emoji clusters)","Strip hidden characters and trailing whitespace","Surface the error's curr/max values to end users"],"tags":["validation","length-limit","content","xiaohongshu"],"backgroundTag":"content-length-exceeded","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"}