{"record":{"id":"47e07e4d487fc7a0","repo":"xpzouying/xiaohongshu-mcp","slug":"error-47e07e","errorCode":null,"errorMessage":"绑定商品失败","messagePattern":"绑定商品失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":402,"sourceCode":"\t\t\treturn errors.Wrap(err, \"设置定时发布失败\")\n\t\t}\n\t\tslog.Info(\"定时发布设置完成\", \"schedule_time\", scheduleTime.Format(\"2006-01-02 15:04\"))\n\t}\n\n\tif err := setVisibility(page, visibility); err != nil {\n\t\treturn errors.Wrap(err, \"设置可见范围失败\")\n\t}\n\n\t// 处理原创声明：显式请求了原创但设置失败 → 报错中止，不静默发成非原创（避免\"以为原创其实不是\"）\n\tif isOriginal {\n\t\tif err := setOriginal(page); err != nil {\n\t\t\treturn errors.Wrap(err, \"设置原创声明失败（已请求原创，中止发布）\")\n\t\t}\n\t\tslog.Info(\"已声明原创\")\n\t}\n\n\tif err := bindProducts(ctx, page, products); err != nil {\n\t\treturn errors.Wrap(err, \"绑定商品失败\")\n\t}\n\n\tif err := clickPublishButton(page); err != nil {\n\t\treturn err\n\t}\n\n\t// 校验发布真的成功：成功后创作平台会跳转离开发布页；未跳转则判定失败，\n\t// 消除\"点了发布按钮就算成功\"的假阳性。\n\treturn waitPublishSuccess(page, 15*time.Second)\n}\n\n// waitPublishSuccess 轮询等待发布成功的信号：小红书发布成功后会跳转离开发布表单页\n// （URL 不再含 /publish/publish）。超时仍未跳转 → 判定发布失败。\nfunc waitPublishSuccess(page *rod.Page, timeout time.Duration) error {\n\tdeadline := time.Now().Add(timeout)\n\tfor {\n\t\tif info, err := page.Info(); err == nil && !strings.Contains(info.URL, \"/publish/publish\") {\n\t\t\tslog.Info(\"发布成功，已跳转离开发布页\", \"url\", info.URL)","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L384-L420","documentation":"Raised in submitPublish when bindProducts fails to attach the requested product links to the note. It wraps the underlying DOM/commerce-panel error so the caller knows binding products, not another publish step, failed.","triggerScenarios":"Calling Publish with a non-empty products list while the product-binding panel cannot be opened, no products match, or the product selection UI fails to interact.","commonSituations":"Account lacks product-binding/commerce permission; product IDs no longer exist or are off-shelf; Xiaohongshu changed the product panel DOM.","solutions":["Confirm the account has commerce/product-binding access on Xiaohongshu","Verify each product ID is valid and on-shelf","Call Publish with an empty products list if binding is optional","Inspect the wrapped cause and update the library if the product panel DOM changed"],"exampleFix":"// before\nerr := xhs.Publish(..., products=[]string{\"999999\"}) // invalid/off-shelf product\n// after\nerr := xhs.Publish(..., products=validOnShelfProductIDs) // filtered/validated IDs","handlingStrategy":"validation","validationCode":"for _, id := range products {\n    if !isOnShelf(id) { return errors.Errorf(\"商品 %s 已下架或无效\", id) }\n}\nif !accountHasCommerceAccess { products = nil }","typeGuard":null,"tryCatchPattern":"if err := xhs.Publish(...); err != nil {\n    if strings.Contains(err.Error(), \"绑定商品失败\") {\n        // retry without products, or fix product list\n    }\n}","preventionTips":["Validate product IDs are valid and on-shelf before publish","Verify the account has product-binding permission","Fall back to publishing without products if binding is optional","Update library after commerce-panel UI changes"],"tags":["browser-automation","rod","commerce"],"backgroundTag":"product-binding-failed","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}