{"record":{"id":"7eae2de15343d9f1","repo":"abi/screenshot-to-code","slug":"invalid-generation-type-generation-type","errorCode":null,"errorMessage":"Invalid generation type: {generation_type}","messagePattern":"Invalid generation type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/routes/generate_code.py","lineNumber":335,"sourceCode":"        # Base URL for OpenAI API\n        openai_base_url: str | None = None\n        # Disable user-specified OpenAI Base URL in prod\n        if not IS_PROD:\n            openai_base_url = self._get_from_settings_dialog_or_env(\n                params, \"openAiBaseURL\", OPENAI_BASE_URL\n            )\n        if not openai_base_url:\n            print(\"Using official OpenAI URL\")\n\n        # Feature preferences default to enabled for older clients.\n        should_generate_images = bool(params.get(\"isImageGenerationEnabled\", True))\n        should_extract_assets = bool(params.get(\"isAssetExtractionEnabled\", True))\n\n        # Extract and validate generation type\n        generation_type = params.get(\"generationType\", \"create\")\n        if generation_type not in [\"create\", \"update\"]:\n            await self.throw_error(f\"Invalid generation type: {generation_type}\")\n            raise ValueError(f\"Invalid generation type: {generation_type}\")\n        generation_type = cast(Literal[\"create\", \"update\"], generation_type)\n\n        # Extract prompt content\n        prompt: UserTurnInput = parse_prompt_content(params.get(\"prompt\"))\n\n        # Extract history (default to empty list)\n        history: List[PromptHistoryMessage] = parse_prompt_history(\n            params.get(\"history\")\n        )\n\n        prompt = append_uploaded_asset_ids_to_prompt(prompt, self.asset_base_url)\n        history = append_uploaded_asset_ids_to_history(history, self.asset_base_url)\n\n        # Extract file state for agent edits\n        raw_file_state = params.get(\"fileState\")\n        file_state: Dict[str, str] | None = None\n        if isinstance(raw_file_state, dict):\n            content = raw_file_state.get(\"content\")","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/generate_code.py#L317-L353","documentation":"Error emitted via throw_error in backend/routes/generate_code.py:335 when params['generationType'] (defaulting to 'create') is not 'create' or 'update'. The backend only supports creating a new project from a screenshot or updating an existing one; any other value is rejected.","triggerScenarios":"WebSocket request with generationType: 'edit', 'refine', missing-then-defaulted incorrectly (e.g. null, which is not 'create'), or any third-party extension value.","commonSituations":"Clients written against a different tool's terminology; frontend sending null instead of omitting the field; custom workflows trying to invoke modes this backend does not have.","solutions":["Send generationType: 'create' for new generations or 'update' when passing chat history for an update.","Omit the field entirely if you want the 'create' default — do not send null.","Implement edit/refine flows as 'update' with an appropriate prompt."],"exampleFix":"// before\npayload.generationType = mode === 'edit' ? 'edit' : 'create';\n\n// after\npayload.generationType = mode === 'update' ? 'update' : 'create';","handlingStrategy":"validation","validationCode":"const GENERATION_TYPES = ['create', 'update'] as const;\nif (!GENERATION_TYPES.includes(generationType)) {\n  generationType = hasHistory ? 'update' : 'create';\n}\nif (generationType === null) delete payload.generationType; // rely on 'create' default","typeGuard":"function isGenerationType(v: unknown): v is 'create' | 'update' {\n  return v === 'create' || v === 'update';\n}","tryCatchPattern":"if (msg.type === 'error' && msg.message.startsWith('Invalid generation type')) {\n  // coerce to 'create' or 'update' and resend\n}","preventionTips":["Never send null for generationType — omit the key to get the default.","Map any custom mode names onto create/update before sending."],"tags":["websocket","validation","generate-code","generation-type"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}