{"record":{"id":"e69ac4e1342ef139","repo":"xpzouying/xiaohongshu-mcp","slug":"s-e69ac4","errorCode":null,"errorMessage":"长度超过限制: %s","messagePattern":"长度超过限制: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":638,"sourceCode":"\t\treturn errors.Wrap(err, \"检查正文长度元素失败\")\n\t}\n\n\tif !has {\n\t\treturn nil\n\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","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L620-L656","documentation":"This is a fallback error from makeMaxLengthError: the length indicator text retrieved from the page did not contain exactly one '/' separator (expected format like '1002/1000'), so the library cannot parse current vs max length and reports the raw text instead. It signals the site's length-error UI changed format or contained unexpected text.","triggerScenarios":"checkTitleMaxLength or checkContentMaxLength found the over-length indicator element, its text was read successfully, but strings.Split(text, \"/\") did not yield exactly 2 parts — e.g. text is '超出字数限制' or contains multiple '/' characters.","commonSituations":"Xiaohongshu front-end redesign changed the indicator format (e.g. no slash, or '1002 / 1000' with spaces handled, or extra characters); a localized or partial-render message; scraping a stale DOM snapshot.","solutions":["Log/inspect the raw elemText in the error to see the actual page text and adapt expectations.","Check whether the site changed the indicator format and update makeMaxLengthError parsing accordingly.","Reduce content/title length before publishing so the indicator never appears.","If the text merely has whitespace around '/', trim parts before validation."],"exampleFix":"// before\nparts := strings.Split(elemText, \"/\")\nif len(parts) != 2 {\n    return errors.Errorf(\"长度超过限制: %s\", elemText)\n}\n// after\nparts := strings.Split(strings.TrimSpace(elemText), \"/\")\nparts[0] = strings.TrimSpace(parts[0])\nif len(parts) == 2 {\n    parts[1] = strings.TrimSpace(parts[1])\n}\nif len(parts) != 2 {\n    return errors.Errorf(\"长度超过限制: %s\", elemText)\n}","handlingStrategy":"validation","validationCode":"// ensure content stays under the limit so the indicator never needs parsing\nif utf8.RuneCountInString(content) > 1000 || utf8.RuneCountInString(title) > 20 {\n    return errors.New(\"内容或标题超长，请先截断\")\n}","typeGuard":"func parseLengthIndicator(text string) (curr, max string, ok bool) {\n    parts := strings.Split(strings.TrimSpace(text), \"/\")\n    if len(parts) != 2 {\n        return \"\", \"\", false\n    }\n    return strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1]), true\n}","tryCatchPattern":"err := publisher.Publish(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"长度超过限制: \") {\n    raw := strings.TrimPrefix(err.Error(), \"长度超过限制: \")\n    log.Printf(\"未识别的长度指示格式: %q，请检查站点 DOM 是否变更\", raw)\n}","preventionTips":["Keep title/content within known limits so parsing never runs","Log the raw indicator text to detect site format changes early","Trim whitespace before expecting the 'curr/max' format","Track Xiaohongshu creator-page DOM changes"],"tags":["parsing","dom","length-limit","xiaohongshu"],"backgroundTag":"unexpected-dom-text-format","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}