{"record":{"id":"9c60a24f16c2a97d","repo":"abi/screenshot-to-code","slug":"invalid-generated-code-config-generated-code-con","errorCode":null,"errorMessage":"Invalid generated code config: {generated_code_config}","messagePattern":"Invalid generated code config: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/routes/generate_code.py","lineNumber":292,"sourceCode":"    \"\"\"Handles parameter extraction and validation from WebSocket requests\"\"\"\n\n    def __init__(\n        self,\n        throw_error: Callable[[str], Coroutine[Any, Any, None]],\n        asset_base_url: str = \"\",\n    ):\n        self.throw_error = throw_error\n        self.asset_base_url = asset_base_url\n\n    async def extract_and_validate(self, params: Dict[str, Any]) -> ExtractedParams:\n        \"\"\"Extract and validate all parameters from the request\"\"\"\n        # Read the code config settings (stack) from the request.\n        generated_code_config = params.get(\"generatedCodeConfig\", \"\")\n        if generated_code_config not in get_args(Stack):\n            await self.throw_error(\n                f\"Invalid generated code config: {generated_code_config}\"\n            )\n            raise ValueError(f\"Invalid generated code config: {generated_code_config}\")\n        validated_stack = cast(Stack, generated_code_config)\n\n        # Validate the input mode\n        input_mode = params.get(\"inputMode\")\n        if input_mode not in get_args(InputMode):\n            await self.throw_error(f\"Invalid input mode: {input_mode}\")\n            raise ValueError(f\"Invalid input mode: {input_mode}\")\n        validated_input_mode = cast(InputMode, input_mode)\n\n        openai_api_key = self._get_from_settings_dialog_or_env(\n            params, \"openAiApiKey\", OPENAI_API_KEY\n        )\n\n        # If neither is provided, we throw an error later only if Claude is used.\n        anthropic_api_key = self._get_from_settings_dialog_or_env(\n            params, \"anthropicApiKey\", ANTHROPIC_API_KEY\n        )\n        gemini_api_key = self._get_from_settings_dialog_or_env(","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/routes/generate_code.py#L274-L310","documentation":"Error emitted through the WebSocket throw_error channel by ExtractedParams.extract_and_validate in backend/routes/generate_code.py:292 when params['generatedCodeConfig'] is not one of the allowed Stack literals (e.g. 'react'/'react_tailwind'/'html', per the Stack type). A plain ValueError is raised afterwards as a backstop, so this is a strict allowlist check on the stack parameter.","triggerScenarios":"Sending a generation request over the WebSocket with generatedCodeConfig missing (defaults to ''), misspelled, or from a newer/older frontend that uses a stack name this backend build does not know.","commonSituations":"Frontend/backend version skew after a new stack was added on one side only; stale open browser tab after a backend upgrade; hand-crafted WebSocket client.","solutions":["Send one of the stack values the backend defines (check the Stack Literal in video/utils/constants or the settings UI).","Refresh the frontend so its stack list matches the backend build.","If you maintain a custom client, fetch the supported stacks from the backend config/UI instead of hardcoding."],"exampleFix":"// before\nws.send(JSON.stringify({ generatedCodeConfig: 'react-tailwind', ... }));\n\n// after\nws.send(JSON.stringify({ generatedCodeConfig: 'react_tailwind', ... })); // exact Stack literal","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"type Stack = 'react' | 'react_tailwind' | 'html' | 'mock' | 'vue' | 'angular' | 'svelte' | 'html_tailwind';\nconst STACKS: Stack[] = ['react', 'react_tailwind', 'html', /* ... */];\nfunction isStack(v: unknown): v is Stack {\n  return typeof v === 'string' && (STACKS as string[]).includes(v);\n}","tryCatchPattern":"ws.onmessage = (ev) => {\n  const msg = JSON.parse(ev.data);\n  if (msg.type === 'error' && msg.message.startsWith('Invalid generated code config')) {\n    // refresh supported stacks / fix the payload before retry\n  }\n};","preventionTips":["Keep frontend and backend versions in lockstep; refresh tabs after backend upgrades.","Source stack values from a shared constant or backend-provided list."],"tags":["websocket","validation","stack-config","generate-code"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}