{"record":{"id":"900ce98606a3dbb6","repo":"invoke-ai/InvokeAI","slug":"unknown-subfolder-strategy-strategy-name-valid","errorCode":null,"errorMessage":"Unknown subfolder strategy: {strategy_name}. Valid options: {', '.join(strategies.keys())}","messagePattern":"Unknown subfolder strategy: (.+?)\\. Valid options: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"invokeai/app/services/image_files/image_subfolder_strategy.py","lineNumber":57,"sourceCode":"\nclass HashStrategy(ImageSubfolderStrategy):\n    \"\"\"Organize images by UUID prefix for filesystem performance (first 2 characters).\"\"\"\n\n    def get_subfolder(self, image_name: str, image_category: ImageCategory, is_intermediate: bool) -> str:\n        return image_name[:2]\n\n\ndef create_subfolder_strategy(strategy_name: str) -> ImageSubfolderStrategy:\n    \"\"\"Factory function to create a subfolder strategy by name.\"\"\"\n    strategies: dict[str, type[ImageSubfolderStrategy]] = {\n        \"flat\": FlatStrategy,\n        \"date\": DateStrategy,\n        \"type\": TypeStrategy,\n        \"hash\": HashStrategy,\n    }\n    cls = strategies.get(strategy_name)\n    if cls is None:\n        raise ValueError(f\"Unknown subfolder strategy: {strategy_name}. Valid options: {', '.join(strategies.keys())}\")\n    return cls()\n","sourceCodeStart":39,"sourceCodeEnd":59,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/image_files/image_subfolder_strategy.py#L39-L59","documentation":"create_subfolder_strategy looks up the strategy name in a fixed registry ('none', 'date', 'type', 'hash'); unknown names raise ValueError listing valid options. This guards the runtime-configurable subfolder strategy setting.","triggerScenarios":"Calling ImageSubfolderStrategyFactory.create (or create_subfolder_strategy) with a misspelled or unsupported name, e.g. 'Date', 'dates', or 'none ' with whitespace; loading an old config value removed in a newer version.","commonSituations":"Typo in config file (images.subfolder_strategy); case mismatch ('Date' vs 'date'); config written for a version whose strategy set differs.","solutions":["Use one of the listed valid names: 'none', 'date', 'type', 'hash'","Lowercase and strip the configured value before passing it in","Update the config to the current version's supported strategy names"],"exampleFix":"// before\ncreate_subfolder_strategy('Date')\n// after\ncreate_subfolder_strategy(config_value.strip().lower())  # 'date'","handlingStrategy":"validation","validationCode":"VALID_STRATEGIES = {'none', 'date', 'type', 'hash'}\ndef strategy_is_valid(cfg: str) -> bool:\n    return cfg.strip().lower() in VALID_STRATEGIES\nassert strategy_is_valid(config.images.subfolder_strategy)","typeGuard":"def is_valid_strategy(v: object) -> bool:\n    return isinstance(v, str) and v.strip().lower() in {'none', 'date', 'type', 'hash'}","tryCatchPattern":"try:\n    strategy = create_subfolder_strategy(config.images.subfolder_strategy)\nexcept ValueError as e:\n    logger.error('%s — falling back to none', e)\n    strategy = create_subfolder_strategy('none')","preventionTips":["Validate config values against the strategy list at startup","Normalize (strip + lowercase) before passing strategy names","Re-check strategy names after upgrading InvokeAI versions"],"tags":["configuration","validation","factory"],"backgroundTag":"invalid-config-value","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}