{"record":{"id":"c860f306a1b6eefd","repo":"abi/screenshot-to-code","slug":"unsupported-model-model-value","errorCode":null,"errorMessage":"Unsupported model: {model.value}","messagePattern":"Unsupported model: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/agent/providers/factory.py","lineNumber":80,"sourceCode":"            prompt_messages=prompt_messages,\n            tools=serialize_anthropic_tools(canonical_tools),\n            recorder=recorder,\n        )\n\n    if model in GEMINI_MODELS:\n        if not gemini_api_key:\n            raise Exception(\"Gemini API key is missing.\")\n\n        client = genai.Client(api_key=gemini_api_key)\n        return GeminiProviderSession(\n            client=client,\n            model=model,\n            prompt_messages=prompt_messages,\n            tools=serialize_gemini_tools(canonical_tools),\n            recorder=recorder,\n        )\n\n    raise ValueError(f\"Unsupported model: {model.value}\")\n","sourceCodeStart":62,"sourceCodeEnd":81,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/agent/providers/factory.py#L62-L81","documentation":"ValueError raised at the bottom of create_provider_session when the model is not in OPENAI_MODELS, ANTHROPIC_MODELS, or GEMINI_MODELS. It is the factory's exhaustive-match fallback: any Llm enum value (or raw string coerced by Llm(model)) that no provider branch claims lands here. The f-string interpolates the concrete model value.","triggerScenarios":"A new model is added to the Llm enum (e.g. in evals/runner.py Llm(model)) but not to the corresponding provider model set, or a raw model string is passed that matches no known family.","commonSituations":"See trigger scenarios.","solutions":["Add the new model id to the correct *_MODELS set (openai/anthropic/gemini) in the providers module.","If it is a genuinely new provider, add a branch in the factory before the final raise.","Check for spelling drift between the enum value and the set membership (whitespace/case)."],"exampleFix":"# before\nOPENAI_MODELS = {Llm.GPT_4O}\n\n# after\nOPENAI_MODELS = {Llm.GPT_4O, Llm.GPT_4_1}","handlingStrategy":"type-guard","validationCode":"known = OPENAI_MODELS | ANTHROPIC_MODELS | GEMINI_MODELS\nif model not in known:\n    raise ValueError(f\"Model {model} not registered; add it to a provider set\")","typeGuard":"def is_supported_model(model: Llm) -> bool:\n    return model in OPENAI_MODELS or model in ANTHROPIC_MODELS or model in GEMINI_MODELS","tryCatchPattern":"try:\n    session = create_provider_session(model=model, ...)\nexcept ValueError as e:\n    if \"Unsupported model\" in str(e):\n        # fall back to a default model or reject the request with 400\n        ...","preventionTips":["Whenever you add an Llm enum value, immediately register it in the matching provider set — treat enum and sets as one change.","Filter model dropdowns from the registry sets, never from a hardcoded list.","Add a unit test asserting every Llm member belongs to exactly one provider set."],"tags":["model-registry","factory","valueerror","extensibility"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}