{"record":{"id":"384caa40e6e9f2be","repo":"jackwener/OpenCLI","slug":"no-model-matched-wantset-available-opts-j","errorCode":null,"errorMessage":"No model matched \"${wantSet}\". Available: ${opts.join(', ')}","messagePattern":"No model matched \"(.+?)\"\\. Available: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/kimi/ui.js","lineNumber":266,"sourceCode":"        .filter((t, i, arr) => arr.indexOf(t) === i)\n        .slice(0, 20);\n    })()`);\n\n        if (wantSet) {\n            const normalizeModel = (value) => String(value || '').toLowerCase().replace(/[^a-z0-9.\\u4e00-\\u9fa5]+/g, '');\n            const needle = normalizeModel(wantSet);\n            const exactIdx = opts.findIndex((t) => normalizeModel(t) === needle);\n            const partialMatches = exactIdx >= 0 ? [] : opts\n                .map((model, index) => ({ model, index }))\n                .filter((item) => normalizeModel(item.model).includes(needle));\n            if (exactIdx < 0 && partialMatches.length > 1) {\n                try { await page.evaluate(`document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));`); } catch {}\n                throw new ArgumentError('set', `Model \"${wantSet}\" is ambiguous: ${partialMatches.map(item => item.model).join(', ')}`);\n            }\n            const idx = exactIdx >= 0 ? exactIdx : partialMatches[0]?.index ?? -1;\n            if (idx < 0) {\n                try { await page.evaluate(`document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));`); } catch {}\n                throw new ArgumentError('set', `No model matched \"${wantSet}\". Available: ${opts.join(', ')}`);\n            }\n            const clickRes = await page.evaluate(`(() => {\n        ${IS_VISIBLE_JS}\n        const popovers = Array.from(document.querySelectorAll('[class*=\"popover\"i], [class*=\"dropdown\"i], [role=\"menu\"], [role=\"listbox\"]')).filter(isVisible);\n        const pop = popovers[popovers.length - 1];\n        if (!pop) return { ok: false };\n        const items = Array.from(pop.querySelectorAll('div, li, button, [role=\"option\"], [role=\"menuitem\"]'))\n          .filter(isVisible)\n          .filter((el) => { const t = (el.innerText || '').trim(); return t && t.length < 80 && (/K\\\\d|Kimi|Pro\\\\b|Auto|思考/.test(t)); });\n        const target = items[${idx}];\n        if (!target) return { ok: false };\n        target.click();\n        return { ok: true, clicked: (target.innerText || '').trim() };\n            })()`);\n            if (!clickRes?.ok) throw new CommandExecutionError('Failed to click model option', '');\n            await page.wait(0.5);\n            const verified = await page.evaluate(`(() => {\n      ${IS_VISIBLE_JS}","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/ui.js#L248-L284","documentation":"When setting the Kimi model, after exact and substring matching against dropdown options, idx remains -1 if nothing matched; the command closes the menu and throws ArgumentError listing every available option. This guarantees the active model is never silently left unchanged.","triggerScenarios":"Calling the kimi model set command with a model name that neither exactly nor partially matches any option rendered in the dropdown, e.g. a discontinued or renamed model string.","commonSituations":"Hardcoded model name from an older Kimi version; typo ('Kimi K3'); region/account lacking certain models so they never appear as options.","solutions":["Use one of the exact names printed in the error's Available: list.","Run the model list command to enumerate current options and update scripts.","Check your Kimi account/region exposes the requested model.","Update the library if model names changed upstream."],"exampleFix":"// before\nawait run('kimi', 'model', { set: 'Kimi K1.5' }); // no longer offered\n// after\nawait run('kimi', 'model', { set: 'Kimi K2' }); // from Available list","handlingStrategy":"validation","validationCode":"const models = await run('kimi', 'model');\nconst ok = models.some(m => normalize(m.Model) === normalize(want));\nif (!ok) throw new Error(`\"${want}\" not offered; use: ${models.map(m => m.Model).join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  await run('kimi', 'model', { set: want });\n} catch (e) {\n  if (/No model matched/.test(e.message)) {\n    const available = e.message.match(/Available: (.*)$/)?.[1].split(', ') ?? [];\n    await run('kimi', 'model', { set: available[0] }); // safe fallback\n  } else throw e;\n}","preventionTips":["Source model names dynamically from the list command, not hardcoded literals.","Pin known-good model names in config with a startup validation check.","Re-check names after Kimi version/deployment changes."],"tags":["argument-validation","kimi","model-selection"],"backgroundTag":"model-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}