xpzouying/xiaohongshu-mcp · warning

读取新版发布按钮 submit-disabled 属性失败

Error message

读取新版发布按钮 submit-disabled 属性失败

What it means

findPublishButton 遍历新版发布按钮 widget 时读取 submit-disabled 属性的 Attribute 调用失败:元素在遍历过程中被重渲染/销毁,CDP 属性查询报错。与按钮被禁用(值判断)不同,这里是读取本身失败。

Source

Thrown at xiaohongshu/publish.go:502

		return nil, "", errors.Wrap(err, "查找新版发布按钮失败")
	}

	for _, widget := range widgets {
		if !isElementVisible(widget) {
			continue
		}

		isPublish, err := widget.Attribute("is-publish")
		if err != nil {
			return nil, "", errors.Wrap(err, "读取新版发布按钮 is-publish 属性失败")
		}
		if isPublish != nil && *isPublish == "false" {
			continue
		}

		submitDisabled, err := widget.Attribute("submit-disabled")
		if err != nil {
			return nil, "", errors.Wrap(err, "读取新版发布按钮 submit-disabled 属性失败")
		}
		if submitDisabled != nil && *submitDisabled == "true" {
			return &publishButton{elem: widget, isWidget: true}, "新版发布按钮不可点击", nil
		}

		return &publishButton{elem: widget, isWidget: true}, "", nil
	}

	oldButtons, err := page.Elements(".publish-page-publish-btn button.bg-red")
	if err != nil {
		return nil, "", errors.Wrap(err, "查找旧版发布按钮失败")
	}

	for _, oldButton := range oldButtons {
		if !isElementVisible(oldButton) {
			continue
		}

View on GitHub (pinned to 332d196854)

Solutions

  1. Transient — the polling loop retries each second; retry the whole publish if it propagates
  2. Reduce concurrent activity on the page during publish
  3. Verify browser health and stability
  4. Update the library if the failure becomes persistent after a Xiaohongshu frontend change
Defensive patterns

Strategy: retry

Try / catch

err := xhs.Publish(...)
if err != nil && strings.Contains(err.Error(), "submit-disabled 属性失败") {
    err = xhs.Publish(...) // 瞬时读取失败,重试
}

Prevention

When it happens

Trigger: widget.Attribute("submit-disabled") errors due to a detached element, destroyed execution context, or browser connection failure during the attribute read.

Common situations: Element replaced by a re-render mid-inspection; page navigation; resource-constrained browser dropping CDP responses.

Related errors


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