{"record":{"id":"ac109353eb42b1d3","repo":"jackwener/OpenCLI","slug":"gemini-model-discovery-returned-a-malformed-row","errorCode":null,"errorMessage":"Gemini model discovery returned a malformed row","messagePattern":"Gemini model discovery returned a malformed row","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gemini/ask.js","lineNumber":43,"sourceCode":" * Validate a --model value for gemini ask.\n * Throws ArgumentError for short aliases or invalid formats.\n */\nfunction unwrapBrowserBridgeEnvelope(value) {\n    if (value && typeof value === 'object' && !Array.isArray(value) && 'session' in value) {\n        if ('data' in value) return value.data;\n        throw new CommandExecutionError('Gemini model discovery returned a malformed Browser Bridge envelope');\n    }\n    return value;\n}\n\nfunction requireDiscoveredModels(value) {\n    const unwrapped = unwrapBrowserBridgeEnvelope(value);\n    if (!Array.isArray(unwrapped)) {\n        throw new CommandExecutionError('Gemini model discovery returned a malformed result');\n    }\n    for (const row of unwrapped) {\n        if (!row || typeof row.model !== 'string' || !Array.isArray(row.thinkingValues)) {\n            throw new CommandExecutionError('Gemini model discovery returned a malformed row');\n        }\n    }\n    return unwrapped;\n}\n\nfunction validateAskModelValue(value) {\n    if (!value) {\n        throw new ArgumentError(\n            '--model requires a canonical model id (e.g. \"2.5-flash\"). ' +\n            'Use \"opencli gemini models\" to list available values.'\n        );\n    }\n    // Reject short aliases like \"pro\", \"flash\", \"flash-lite\" that lack a version number.\n    if (!/\\d+\\.\\d+/.test(value)) {\n        throw new ArgumentError(\n            '--model \"' + value + '\" is not accepted. ' +\n            'Short aliases like \"pro\", \"flash\", or \"flash-lite\" are not supported. ' +\n            'Use a canonical model id (e.g. \"2.5-flash\"). ' +","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/ask.js#L25-L61","documentation":"requireDiscoveredModels in clis/gemini/ask.js validates each row of the discovered model list: every row must be a truthy object with a string `model` and an array `thinkingValues`. Any row failing this shape triggers this CommandExecutionError, preventing malformed rows from reaching the model picker or thinking-level logic.","triggerScenarios":"`opencli gemini ask` performs discovery and at least one element of the model array is null, a plain string, or an object missing `model`/`thinkingValues` (or with non-array `thinkingValues`).","commonSituations":"Gemini introduces a new model card variant the extraction script doesn't fully parse; partial page load leaves one row half-populated; UI A/B test changes row markup for a single model.","solutions":["Retry the command after the page fully loads to rule out a partially rendered row","Update opencli so the row extractor matches the current Gemini model-card markup","As a workaround, pass an explicit `--model 2.5-flash` and valid `--thinking` value if your CLI version permits skipping discovery-dependent selection"],"exampleFix":"null","handlingStrategy":"type-guard","validationCode":"for (const row of discovered) {\n  if (!row || typeof row.model !== 'string' || !Array.isArray(row.thinkingValues)) {\n    console.warn('Skipping malformed discovery row:', row);\n  }\n}","typeGuard":"function isValidModelRow(row) {\n  return !!row && typeof row.model === 'string' && Array.isArray(row.thinkingValues);\n}","tryCatchPattern":"try {\n  const models = await geminiAsk(args);\n} catch (err) {\n  if (err.message.includes('malformed row')) {\n    return geminiAsk({ ...args, model: '2.5-flash' }); // bypass picker\n  }\n  throw err;\n}","preventionTips":["Update the CLI when Gemini model-card markup changes","Prefer explicit --model over interactive discovery in CI","Retry once in case a row was partially rendered","Validate rows client-side and filter invalid ones before selection"],"tags":["model-discovery","schema-validation","gemini"],"backgroundTag":"model-discovery-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}