{"record":{"id":"309740430f20df9e","repo":"jackwener/OpenCLI","slug":"result-reason-failed-to-select-gemini-model","errorCode":null,"errorMessage":"result?.reason || 'Failed to select Gemini model \"' + modelId + '\"'","messagePattern":"result\\?\\.reason \\|\\| 'Failed to select Gemini model \"' \\+ modelId \\+ '\"'","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gemini/utils.js","lineNumber":2739,"sourceCode":"    await ensureGeminiPage(page);\n\n    // Open the picker menu.\n    const pickerRaw = await page.evaluate(openModelPickerForThinkingScript());\n    const pickerResult = unwrapGeminiEvaluateResult(pickerRaw, 'Gemini model picker');\n    if (!pickerResult || !pickerResult.ok) {\n        throw new CommandExecutionError(\n            pickerResult?.reason || 'Failed to open model picker for model selection'\n        );\n    }\n\n    // Wait for React to render the menu.\n    await page.wait(0.8);\n\n    // Find and click the matching menu item.\n    const raw = await page.evaluate(selectModelInMenuScript(modelId));\n    const result = unwrapGeminiEvaluateResult(raw, 'Gemini model selection');\n    if (!result || !result.ok) {\n        throw new CommandExecutionError(\n            result?.reason || 'Failed to select Gemini model \"' + modelId + '\"'\n        );\n    }\n\n    await page.wait(0.5);\n    const selectedModelId = await getCurrentGeminiModel(page);\n    if (selectedModelId !== modelId) {\n        throw new CommandExecutionError(\n            selectedModelId\n                ? `Gemini model selection read-back returned \"${selectedModelId}\", expected \"${modelId}\"`\n                : `Gemini model selection did not expose selected model \"${modelId}\" after click`\n        );\n    }\n}\n","sourceCodeStart":2721,"sourceCodeEnd":2754,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/utils.js#L2721-L2754","documentation":"CommandExecutionError thrown when the in-page script that clicks the matching model menu item reports failure. The picker opened, but selecting the requested modelId inside the menu failed.","triggerScenarios":"selectModelInMenuScript(modelId) at clis/gemini/utils.js:2739 returns ok:false or a reason — the menu item for modelId was not found or the click did not register.","commonSituations":"Requesting a model id/name that no longer exists in the menu; model renamed by Google; menu rendered before items hydrated; account lacks access to the requested model.","solutions":["Verify the exact modelId matches a menu entry (use the model listing command if available)","Re-run after the menu fully renders","Update the CLI for current Gemini menu DOM"],"exampleFix":"// before\nopencli gemini model --set gemini-1.5-ultra\n// after\nopencli gemini model --set gemini-2.5-pro","handlingStrategy":"retry","validationCode":"const KNOWN_MODELS = ['gemini-2.5-pro','gemini-2.5-flash'];\nif (!KNOWN_MODELS.includes(modelId)) {\n  throw new Error(`Unknown modelId '${modelId}' — use an exact menu entry name`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await selectGeminiModel(page, modelId);\n} catch (err) {\n  if (err.message.includes('Failed to select Gemini model')) {\n    const list = await listGeminiModels(page);\n    console.error(`Model '${modelId}' not found. Available: ${list.join(', ')}`);\n  }\n  throw err;\n}","preventionTips":["Use the exact model name shown in the picker menu","Confirm your account has access to the requested model","Retry after the menu finishes rendering"],"tags":["browser-automation","dom","gemini"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}