{"record":{"id":"be50dffde938293b","repo":"jackwener/OpenCLI","slug":"model-requires-a-canonical-model-id-e-g-2-5-f","errorCode":null,"errorMessage":"--model requires a canonical model id (e.g. \"2.5-flash\"). Use \"opencli gemini models\" to list available values.","messagePattern":"--model requires a canonical model id \\(e\\.g\\. \"2\\.5-flash\"\\)\\. Use \"opencli gemini models\" to list available values\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/gemini/ask.js","lineNumber":51,"sourceCode":"    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\"). ' +\n            'Use \"opencli gemini models\" to list available values.'\n        );\n    }\n    // Must match canonical format: X.Y-variant\n    if (!/^\\d+\\.\\d+-[a-z][a-z-]*$/.test(value)) {\n        throw new ArgumentError(\n            '--model \"' + value + '\" is not a valid canonical model id. ' +\n            'Expected format: version-variant (e.g. \"2.5-flash\", \"3.1-pro\"). ' +","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/ask.js#L33-L69","documentation":"validateAskModelValue in clis/gemini/ask.js throws this ArgumentError when `--model` is omitted, empty, or falsy. The gemini ask command requires a canonical model id such as `2.5-flash`; it will not guess or default. The message points to `opencli gemini models` for the list of valid values.","triggerScenarios":"Running `opencli gemini ask --prompt \"...\"` without `--model`, or with `--model \"\"` / `--model` followed by no value.","commonSituations":"Copy-pasting an example command that omitted the flag; assuming a default model exists; a script variable holding the model id being empty due to unset config/env value.","solutions":["Add an explicit canonical model id: `opencli gemini ask --model 2.5-flash ...`","Run `opencli gemini models` to see valid canonical ids, then pick one","Fix the empty variable in your wrapper script (e.g. check `${MODEL_ID:?unset}` before invoking)"],"exampleFix":"// before\nopencli gemini ask --prompt \"hello\"\n// after\nopencli gemini ask --model 2.5-flash --prompt \"hello\"","handlingStrategy":"validation","validationCode":"if (!process.argv.includes('--model')) {\n  console.error('gemini ask requires --model <version-variant>, e.g. --model 2.5-flash');\n  process.exit(2);\n}","typeGuard":"function hasModelArg(args) {\n  return typeof args.model === 'string' && args.model.trim().length > 0;\n}","tryCatchPattern":"try {\n  await geminiAsk(args);\n} catch (err) {\n  if (err.name === 'ArgumentError' && err.message.includes('requires a canonical model id')) {\n    console.error('Usage: opencli gemini ask --model 2.5-flash --prompt \"...\"');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Always pass --model explicitly in scripts","Default MODEL_ID in config with a non-empty canonical value like 2.5-flash","Use ${MODEL_ID:?} shell guards to fail fast on empty variables","Run `opencli gemini models` to pick valid ids"],"tags":["argument-validation","cli","gemini"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}