{"record":{"id":"f1088ed746864937","repo":"jackwener/OpenCLI","slug":"requested-style-stylename-is-not-availa","errorCode":null,"errorMessage":"文字配图: requested style \"${styleName}\" is not available for this content (options: ${(available?.styles || []).join(' / ') || 'none'}). Choose an available style or omit --card-style to use ${DEFAULT_CARD_STYLE}.","messagePattern":"文字配图: requested style \"(.+?)\" is not available for this content \\(options: (.+?)\\)\\. Choose an available style or omit --card-style to use (.+?)\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/publish.js","lineNumber":957,"sourceCode":"      const scroller = document.querySelector('.cover-list-container-wrapper')\n        || document.querySelector('.cover-list-container');\n      if (scroller) {\n        const ch = scroller.clientHeight || 200;\n        const sh = scroller.scrollHeight;\n        for (let y = 0; y <= sh + ch; y += Math.max(60, Math.floor(ch / 2))) {\n          scroller.scrollTop = y;\n          await new Promise((r) => setTimeout(r, 180));\n          readAll();\n          hit = target();\n          if (hit) { reveal(hit); await new Promise((r) => setTimeout(r, 150)); return { ok: true, styles: seen, found: true }; }\n        }\n        scroller.scrollTop = 0;\n      }\n      return { ok: seen.length > 0, styles: seen, found: false };\n    })()\n  `));\n    if (!available?.found) {\n        throw new CommandExecutionError(`文字配图: requested style \"${styleName}\" is not available for this content `\n            + `(options: ${(available?.styles || []).join(' / ') || 'none'}). `\n            + `Choose an available style or omit --card-style to use ${DEFAULT_CARD_STYLE}.`);\n    }\n    const clicked = await clickByText(page, styleName);\n    if (!clicked?.ok) {\n        throw new CommandExecutionError(`文字配图: could not click requested style \"${styleName}\".`);\n    }\n    await page.wait({ time: 0.6 });\n    return styleName;\n}\n/**\n * Count visible media in the current editor/composer. Text-image generation must\n * produce real image cards before we fill title/body or submit; otherwise a\n * no-op 生成图片 / 下一步 sequence can publish the wrong draft surface.\n */\nasync function currentComposerMediaCount(page) {\n    const result = await page.evaluate(`\n    (() => {","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L939-L975","documentation":"selectCardStyle scrolls the lazy-loaded style strip, reads the real on-page style labels, and throws if the requested styleName was not among them. The error lists the actually available styles so the caller can pick one or omit --card-style to fall back to DEFAULT_CARD_STYLE.","triggerScenarios":"--card-style <name> was passed but no label in the style strip matched it exactly (clickByText matches on rendered text), either because the style doesn't exist for this content or the name is misspelled/renamed by XHS.","commonSituations":"Hard-coded style name from an older XHS version no longer offered; typo or differing whitespace in the style name; style strip failed to lazy-load so the list is empty ('none'); style unavailable for the particular card content.","solutions":["Pick one of the styles listed in the error message's options, or omit --card-style to use the default.","Fix the style name to match XHS's exact on-page label (case/spacing included).","Re-run if options were 'none' — the strip may not have finished lazy-loading; add a wait before the flow.","If a style you expect is missing, check the XHS UI manually; XHS rotates available styles."],"exampleFix":"// before\nnode publish.js --text-image --card-style \"奶油风\" ...\n// after\nnode publish.js --text-image --card-style \"治愈风\" ...  // a label actually offered, or drop --card-style","handlingStrategy":"validation","validationCode":"const available = await listCardStyles(page); // read strip labels first\nif (!available.includes(styleName)) {\n  console.warn(`style \"${styleName}\" unavailable; using default`);\n  styleName = undefined; // fall back to DEFAULT_CARD_STYLE\n}","typeGuard":"null","tryCatchPattern":"try { await selectCardStyle(page, styleName); }\ncatch (e) {\n  if (/is not available/.test(e.message)) {\n    // parse options from message and pick first, or omit style\n    await selectCardStyle(page, (e.message.match(/options: (.*)\\)/)?.[1] || '').split(' / ')[0]);\n  } else throw e;\n}","preventionTips":["Copy style names exactly as shown in the XHS UI","Don't hard-code styles — read the strip labels at runtime","Omit --card-style to always use the safe default"],"tags":["validation","xhs-dom","cli-argument"],"backgroundTag":"invalid-option-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}