xpzouying/xiaohongshu-mcp · warning

未找到原创声明选项

Error message

未找到原创声明选项

What it means

setOriginal searches the publish page for the original-declaration (原创声明) toggle/checkbox and throws this error if no matching option is found. The library looks for the declaration switch in the publish form; absence means the account/page variant doesn't expose the option, the page hasn't rendered the settings section, or XHS changed the toggle's markup.

Solutions

  1. Only call setOriginal when the option is expected to exist, or tolerate this error in the caller (log a warning, continue publishing without the declaration)
  2. Open any collapsed '更多设置/高级选项' panel before searching for the toggle
  3. Wait for the settings section to render before querying the toggle
  4. Re-inspect the current XHS publish DOM and update the toggle selector if it changed

Example fix

// before
return errors.New("未找到原创声明选项")
// after
return errors.New("未找到原创声明选项") // caller:
if err := setOriginal(page); err != nil {
	slog.Warn("设置原创声明失败,跳过", "error", err) // 不阻断发布
}
Defensive patterns

Strategy: try-catch

Try / catch

if err := setOriginal(page); err != nil {
	if strings.Contains(err.Error(), "未找到原创声明选项") {
		slog.Warn("账号可能无原创权限,跳过原创声明", "error", err)
		return nil // 不阻断发布流程
	}
	return err
}

Prevention

When it happens

Trigger: submitPublish calls setOriginal after filling content; the toggle selector matches nothing — option collapsed behind an '更多设置' expander that wasn't opened, page still loading, or the account has no 原创声明 eligibility (so XHS hides the option entirely).

Common situations: New accounts or accounts without originality permission where XHS hides the switch; the settings section rendered inside a collapsed panel; XHS redesign renaming the toggle element; clicking too early before the form bottom rendered.

Related errors


AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05). Data as JSON: /api/errors/7714928104b4798d. Report an issue: GitHub.

Appendix: source

Thrown at xiaohongshu/publish.go:1031

		}

		// 点击开关
		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)
	}

	time.Sleep(500 * time.Millisecond) // 技术等待:勾选后等"声明原创"按钮变可用

	footer, err := findFooterByText(page, "声明原创")
	if err != nil {
		return errors.Wrap(err, "未找到声明原创弹窗")

View on GitHub (pinned to 332d196854)