{"record":{"id":"75f1bdaf65e30e94","repo":"jackwener/OpenCLI","slug":"gemini-model-discovery-returned-no-selectable-mode","errorCode":null,"errorMessage":"Gemini model discovery returned no selectable models. Gemini Web may have changed its model selector UI.","messagePattern":"Gemini model discovery returned no selectable models\\. Gemini Web may have changed its model selector UI\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gemini/ask.js","lineNumber":172,"sourceCode":"            // Wait for React to render the menu.\n            await page.wait(1.0);\n\n            // Read model entries from the open menu.\n            const raw = await page.evaluate(readMenuModelsScript());\n            discoveredModels = requireDiscoveredModels(raw);\n\n            // Close the menu. Thinking support is intentionally not copied from\n            // the currently-visible UI into every model row: Gemini exposes\n            // thinking controls for the current selection, not a reliable\n            // per-model capability matrix.\n            await page.evaluate(`(() => { try { document.body.click(); } catch (_) {} })()`);\n        }\n\n        // ── Model selection ──────────────────────────────────────────────\n        if (hasModel) {\n            const availableModels = discoveredModels || [];\n            if (!Array.isArray(availableModels) || availableModels.length === 0) {\n                throw new CommandExecutionError(\n                    'Gemini model discovery returned no selectable models. Gemini Web may have changed its model selector UI.'\n                );\n            }\n            const availableIds = availableModels.map((m) => m?.model).filter(Boolean);\n            if (!availableIds.includes(modelValue)) {\n                throw new ArgumentError(\n                    'Unknown model \"' + modelValue + '\". ' +\n                    'Available models: ' + availableIds.join(', ') + '. ' +\n                    'Use \"opencli gemini models\" to see available values.'\n                );\n            }\n            await selectGeminiModel(page, modelValue);\n        }\n\n        // ── Thinking validation and selection ──────────────────────────\n        if (hasThinking) {\n            // Reuse the pre-discovered models from the shared discovery call.\n            const discovered = discoveredModels || [];","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/ask.js#L154-L190","documentation":"Thrown when Gemini model discovery succeeded mechanically but returned an empty list of selectable models, while a --model value was requested. The library treats this as a sign the Gemini Web model-selector UI changed and models could no longer be scraped.","triggerScenarios":"hasModel is true but `discoveredModels` is null, not an array, or an empty array at clis/gemini/ask.js:172.","commonSituations":"Gemini redesigned its model menu so scraping yields zero items; picker opened but menu items render late and were read too early; account/region without model menu; A/B-tested UI variants.","solutions":["Update the model-menu scraping selectors in clis/gemini/ask.js to match the current Gemini DOM","Add/retry a longer wait after opening the picker before reading menu items","Run `opencli gemini models` to see whether discovery works standalone and inspect its raw output","Omit --model so the command uses the default model instead of discovery"],"exampleFix":"// before\nawait page.wait(1.0);\nconst models = readMenuItems();\n// after\nawait page.wait(3.0); // give React time to render menu items\nconst models = readMenuItems();","handlingStrategy":"validation","validationCode":"if (!Array.isArray(discoveredModels) || discoveredModels.length === 0) {\n  throw new Error('Model discovery empty — run `opencli gemini models` to diagnose');\n}","typeGuard":"function hasModels(v) { return Array.isArray(v) && v.length > 0 && v.every(m => typeof m?.model === 'string'); }","tryCatchPattern":"try {\n  await askWithModel(model);\n} catch (e) {\n  if (/no selectable models/i.test(e.message)) {\n    // fall back to default model or re-run discovery after a longer wait\n  }\n}","preventionTips":["Call `opencli gemini models` first to confirm discovery works","Allow generous waits for the model menu to render","Pin/verify model IDs after Gemini UI updates","Omit --model when unsure to use the default"],"tags":["gemini","ui-scraping","model-discovery"],"backgroundTag":"ui-scrape-empty-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}