xpzouying/xiaohongshu-mcp · error
确认原创声明失败
Error message
确认原创声明失败
What it means
Thrown by setOriginal wrapping any failure from confirmOriginalDeclaration — the follow-up modal flow after toggling original declaration. The 须知-footer lookup inside confirmOriginalDeclaration is only logged as a warning, so this error almost always means the 声明原创 confirmation footer/button was not found or the button stayed disabled.
Source
Thrown at xiaohongshu/publish.go:1024
if err != nil {
continue
}
if checked.Value.Bool() {
slog.Info("原创声明已开启")
return nil
}
// 点击开关
if err := humanize.Click(switchElem); err != nil {
return errors.Wrap(err, "点击原创声明开关失败")
}
time.Sleep(500 * time.Millisecond)
// 处理原创声明确认弹窗
if err := confirmOriginalDeclaration(page); err != nil {
return errors.Wrap(err, "确认原创声明失败")
}
slog.Info("已开启原创声明")
return nil
}
return errors.New("未找到原创声明选项")
}
// confirmOriginalDeclaration 交互(勾选须知、点声明按钮)走 go-rod 点击;
// 仅用只读 Eval 读取 checkbox 勾选态(不产生交互,无法用属性判断的自定义组件才用)。
func confirmOriginalDeclaration(page *rod.Page) error {
time.Sleep(800 * time.Millisecond) // 技术等待:等确认弹窗渲染
if footer, err := findFooterByText(page, "原创声明须知"); err != nil {
slog.Warn("未找到原创声明确认弹窗的 footer", "error", err)
} else if err := checkFooterCheckbox(footer); err != nil {
slog.Warn("勾选原创声明须知失败", "error", err)View on GitHub (pinned to 332d196854)
Solutions
- Replace fixed sleeps with waits for the modal to actually render and the checkbox to be checked.
- Verify checkFooterCheckbox succeeded before expecting the button to enable.
- Dump page.HTML() after the toggle click to confirm the modal exists and update footer/button selectors.
- Re-run the flow manually in a browser to observe the current modal DOM after an XHS update.
Example fix
// before
time.Sleep(800 * time.Millisecond)
footer, err := findFooterByText(page, "原创声明须知")
// after
time.Sleep(800 * time.Millisecond)
if err := page.Wait("() => document.body.innerText.includes('声明原创')"); err != nil {
return errors.Wrap(err, "确认弹窗未渲染")
}
footer, err := findFooterByText(page, "原创声明须知") Defensive patterns
Strategy: retry
Try / catch
if err := setOriginal(page); err != nil {
if strings.Contains(err.Error(), "确认原创声明失败") {
// 弹窗可能未及时渲染:等待后重试一次
_ = page.Wait("() => document.body.innerText.includes('声明原创')")
time.Sleep(1 * time.Second)
return setOriginal(page)
}
return err
} Prevention
- Wait for modal text to appear rather than trusting fixed 800/500ms sleeps.
- Confirm the 须知 checkbox got checked before expecting the confirm button to enable.
- Log and inspect page HTML when the confirm flow fails to catch XHS dialog redesigns.
- Verify the toggle took effect before invoking the confirm step.
When it happens
Trigger: The confirmation modal never rendered (toggle click had no effect); the modal rendered with different footer markup so findFooterByText("声明原创") missed it; the 须知 checkbox was not checked so the confirm button remained disabled.
Common situations: XHS redesigning the confirm dialog structure; modal render slower than the fixed 800ms+500ms sleeps; the div.d-checkbox selector failing silently so the button stays disabled.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/21fd61df7f2ff2cd.
Report an issue: GitHub.