xpzouying/xiaohongshu-mcp · error

绑定商品失败

Error message

绑定商品失败

What it means

bindProducts attaches commerce products (by keyword search) to the video. Failure is wrapped as "绑定商品失败" — the product-binding UI could not be operated or no matching product was found. Note: this step runs even when Products is an empty slice, depending on bindProducts' internal guard.

Source

Thrown at xiaohongshu/publish_video.go:147

	humanize.Delay(ctx, humanize.AfterType)

	// 处理定时发布
	if scheduleTime != nil {
		if err := setSchedulePublish(ctx, page, *scheduleTime); err != nil {
			return errors.Wrap(err, "设置定时发布失败")
		}
		slog.Info("定时发布设置完成", "schedule_time", scheduleTime.Format("2006-01-02 15:04"))
	}

	// 设置可见范围
	if err := setVisibility(page, visibility); err != nil {
		return errors.Wrap(err, "设置可见范围失败")
	}

	// 绑定商品
	if err := bindProducts(ctx, page, products); err != nil {
		return errors.Wrap(err, "绑定商品失败")
	}

	if err := clickPublishButton(page); err != nil {
		return err
	}

	// 校验发布真的成功(成功跳转离开发布页),未跳转判失败——消除假成功
	return waitPublishSuccess(page, 15*time.Second)
}

View on GitHub (pinned to 332d196854)

Solutions

  1. Verify the account has product-binding (带货) permission in the creator center
  2. Use product keywords that exactly match items in your showcase
  3. Pass nil or an empty Products list if no binding is needed (and confirm bindProducts skips it)
  4. Update the product panel selectors after inspecting current page markup

Example fix

// before
action.PublishVideo(ctx, PublishVideoContent{Products: []string{}})
// after
var products []string = nil // skip binding entirely
if hasProducts { products = []string{"exact product name"} }
action.PublishVideo(ctx, PublishVideoContent{Products: products})
Defensive patterns

Strategy: fallback

Validate before calling

for _, kw := range products {
    if strings.TrimSpace(kw) == "" {
        return errors.New("empty product keyword")
    }
}

Try / catch

if err := bindProducts(ctx, page, products); err != nil {
    if len(products) > 0 {
        log.Printf("product binding failed: %+v — publishing without products", err)
    } // non-fatal when binding is optional
}

Prevention

When it happens

Trigger: bindProducts(ctx, page, products) fails because the 贤物/商品 entry selector changed, product search returned no results for the keywords, the account has no 货架/commerce permission, or an empty-but-non-nil Products slice triggers the binding flow with nothing to select.

Common situations: Creator account without e-commerce/带货 authorization; keyword matches no product in the showcase; popup rendered in an iframe; platform A/B testing changed the product panel markup.

Related errors


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