{"record":{"id":"aaae8f39e3d72d22","repo":"invoke-ai/InvokeAI","slug":"generation-devices-cannot-be-an-empty-list-use-a-aaae8f","errorCode":null,"errorMessage":"generation_devices cannot be an empty list. Use 'auto' or a list of devices.","messagePattern":"generation_devices cannot be an empty list\\. Use 'auto' or a list of devices\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/config/config_default.py","lineNumber":294,"sourceCode":"    )\n\n    # fmt: on\n\n    model_config = SettingsConfigDict(env_prefix=\"INVOKEAI_\", env_ignore_empty=True)\n\n    @field_validator(\"generation_devices\")\n    @classmethod\n    def validate_generation_devices(cls, v: Union[str, list[str]]) -> Union[str, list[str]]:\n        if v == \"auto\":\n            return v\n        # A non-\"auto\" string would otherwise be iterated character-by-character below (rejecting\n        # 'c' from \"cuda:0\"), producing a confusing error. Require an explicit list instead.\n        if isinstance(v, str):\n            raise ValueError(\n                f\"Invalid generation_devices value '{v}'. Use 'auto' or a list of devices, e.g. ['cuda:0', 'cuda:1'].\"\n            )\n        if len(v) == 0:\n            raise ValueError(\"generation_devices cannot be an empty list. Use 'auto' or a list of devices.\")\n        pattern = re.compile(r\"^(cpu|mps|xpu(:\\d+)?|cuda(:\\d+)?)$\")\n        for device in v:\n            if not pattern.match(device):\n                raise ValueError(\n                    f\"Invalid generation device '{device}'. Valid values are 'auto', 'cpu', 'mps', 'cuda', 'cuda:N', \"\n                    \"'xpu', or 'xpu:N'.\"\n                )\n        return v\n\n    @field_validator(\"base_url\")\n    @classmethod\n    def validate_base_url(cls, v: Optional[str]) -> Optional[str]:\n        \"\"\"Normalize the reverse-proxy base path: ensure a single leading slash, no trailing slash.\n\n        Empty values and a bare `/` normalize to `None` (feature disabled).\n\n        Reject base paths whose first segment collides with a real route prefix (`/api`, `/ws`, ...):\n        such a value silently bricks the server in both proxy styles (the sub-path rewrite and","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/config/config_default.py#L276-L312","documentation":"validate_generation_devices explicitly rejects an empty list for generation_devices; an empty sequence carries no device selection, so the validator forces the user to either say 'auto' or name at least one device.","triggerScenarios":"Passing generation_devices: [] in the YAML config, GENERATION_DEVICES='[]' via env, or programmatically constructing InvokeAIAppConfig(generation_devices=[]).","commonSituations":"Commenting out all list entries in YAML leaving an empty key; template configs with placeholder lists left empty; code that builds the list dynamically and ends up with zero devices.","solutions":["Set generation_devices: auto to use automatic device selection","Provide at least one valid device in the list, e.g. ['cuda:0'] or ['cpu']","If the list is built dynamically, fall back to 'auto' when the computed list is empty"],"exampleFix":"// before\ngeneration_devices: []\n// after\ngeneration_devices:\n  - cuda:0","handlingStrategy":"validation","validationCode":"devices = cfg.generation_devices\nif isinstance(devices, list) and len(devices) == 0:\n    devices = 'auto'  # normalize before constructing config","typeGuard":null,"tryCatchPattern":"try:\n    cfg = InvokeAIAppConfig(**overrides)\nexcept ValueError as e:\n    if 'cannot be an empty list' in str(e):\n        overrides['generation_devices'] = 'auto'\n        cfg = InvokeAIAppConfig(**overrides)","preventionTips":["Never leave a generation_devices YAML key with an empty list","Fallback to 'auto' when a dynamically built list is empty","Validate config after template rendering"],"tags":["config","validation","pydantic","devices"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}