{"record":{"id":"9cfeba91f2a45b1b","repo":"jackwener/OpenCLI","slug":"model-value-is-not-a-valid-canonical-model","errorCode":null,"errorMessage":"--model \"${value}\" is not a valid canonical model id. Expected format: version-variant (e.g. \"2.5-flash\", \"3.1-pro\"). Use \"opencli gemini models\" to list available values.","messagePattern":"--model \"(.+?)\" is not a valid canonical model id\\. Expected format: version-variant \\(e\\.g\\. \"2\\.5-flash\", \"3\\.1-pro\"\\)\\. Use \"opencli gemini models\" to list available values\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/gemini/ask.js","lineNumber":67,"sourceCode":"function 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\"). ' +\n            'Use \"opencli gemini models\" to list available values.'\n        );\n    }\n}\n\nexport const __test__ = {\n    validateAskModelValue,\n};\n\nexport const askCommand = cli({\n    site: 'gemini',\n    name: 'ask',\n    access: 'write',\n    description: 'Send a prompt to Gemini and return only the assistant response',\n    domain: GEMINI_DOMAIN,\n    strategy: Strategy.COOKIE,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/ask.js#L49-L85","documentation":"validateAskModelValue in clis/gemini/ask.js performs a final strict format check: the `--model` value must match `/^\\d+\\.\\d+-[a-z][a-z-]*$/` (version-variant, e.g. `2.5-flash`, `3.1-pro`). Values that contain a version but fail the full canonical shape — extra characters, uppercase, underscores, wrong separator — trigger this ArgumentError.","triggerScenarios":"`--model 2.5_flash`, `--model 2.5-Flash`, `--model v2.5-flash`, `--model 2.5-flash-v2X`, or full SDK names like `--model gemini-2.5-flash` pasted from Google AI docs.","commonSituations":"Copy-pasting the full model string (`gemini-2.5-flash`) from Google documentation; typos or stray whitespace; using internal IDs with underscores instead of hyphens.","solutions":["Use only the `version-variant` portion: `--model 2.5-flash`, not `--model gemini-2.5-flash`","Strip any vendor prefix or suffix from the value you copied","Run `opencli gemini models` and copy a listed id verbatim"],"exampleFix":"// before\nopencli gemini ask --model gemini-2.5-flash --prompt \"hi\"\n// after\nopencli gemini ask --model 2.5-flash --prompt \"hi\"","handlingStrategy":"validation","validationCode":"const v = String(args.model || '').trim();\nif (!/^\\d+\\.\\d+-[a-z][a-z-]*$/.test(v)) {\n  throw new Error(`--model must be version-variant like 2.5-flash, got \"${args.model}\"`);\n}","typeGuard":"function isVersionVariant(v) {\n  return typeof v === 'string' && /^\\d+\\.\\d+-[a-z][a-z-]*$/.test(v);\n}","tryCatchPattern":"try {\n  await geminiAsk(args);\n} catch (err) {\n  if (err.name === 'ArgumentError' && err.message.includes('not a valid canonical model id')) {\n    const stripped = String(args.model).replace(/^gemini-/, '');\n    if (isVersionVariant(stripped)) return geminiAsk({ ...args, model: stripped });\n  }\n  throw err;\n}","preventionTips":["Strip vendor prefixes (gemini-) when copying ids from Google docs","Reject/trim whitespace and normalize case before invoking","Copy ids verbatim from `opencli gemini models` output","Centralize model-id validation in one shared helper"],"tags":["argument-validation","cli","gemini"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}