{"record":{"id":"9f2865cb6f7c5b6b","repo":"iflytek/astron-agent","slug":"unknown-strategy-strategy","errorCode":null,"errorMessage":"Unknown strategy: {strategy}","messagePattern":"Unknown strategy: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/workflow/configs/__init__.py","lineNumber":205,"sourceCode":"class EnvLoaderFactory:\n    \"\"\"\n    Factory class to create EnvLoader instances based on strategy.\n    \"\"\"\n\n    @staticmethod\n    def create(strategy: str) -> \"EnvLoader\":\n        \"\"\"\n        Create an EnvLoader instance based on the given strategy.\n        :param strategy: The environment loading strategy (e.g., 'local', 'polaris')\n        :return: An instance of EnvLoader\n        \"\"\"\n        if strategy == EnvStrategy.Local.value:\n            logger.info(\"🔍 Using Local file for configuration management.\")\n            return LocalLoader()\n        if strategy == EnvStrategy.Polaris.value:\n            logger.info(\"🔍 Using Polaris for configuration management.\")\n            return PolarisLoader()\n        raise ValueError(f\"Unknown strategy: {strategy}\")\n\n\ndef set_env() -> None:\n    \"\"\"\n    Set environment variables by loading configuration from environment files.\n\n    This function determines the appropriate configuration file based on the\n    runtime environment (local vs production) and loads the environment\n    variables from the corresponding .env file.\n\n    :raises ValueError: If no configuration file is found\n    :raises Exception: Re-raises any other exceptions that occur during loading\n    \"\"\"\n    strategy = os.getenv(\"CONFIG_TYPE\", EnvStrategy.Local.value)\n    loader = EnvLoaderFactory.create(strategy)\n    loader.load()\n\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/configs/__init__.py#L187-L223","documentation":"ConfigLoader.create raises ValueError when the configured strategy string matches neither EnvStrategy.Local nor EnvStrategy.Polaris. It is the factory guard for the configuration-management loader selection, failing fast at startup before any config is loaded.","triggerScenarios":"Calling ConfigLoader.create(strategy) with a string other than 'local' or 'polaris' (exact value match against EnvStrategy enum); typo in the strategy config value; strategy env var set with wrong casing or whitespace.","commonSituations":"Deployment sets CONFIG_STRATEGY=polaris-hr or 'Polaris' (capitalized) instead of the enum's exact value; copy-pasted config from another service with a different strategy name; new loader added to docs but not implemented.","solutions":["Set the strategy config to one of the exact EnvStrategy values ('local' or 'polaris')","Strip/normalize the strategy string (lower(), .strip()) before calling create","Print EnvStrategy values or check the enum definition to confirm accepted values","Add the missing loader branch in configs/__init__.py if a new backend is genuinely required"],"exampleFix":"// before\nloader = ConfigLoader.create(os.getenv(\"CONFIG_STRATEGY\"))\n// after\nstrategy = (os.getenv(\"CONFIG_STRATEGY\") or \"local\").strip().lower()\nloader = ConfigLoader.create(strategy)","handlingStrategy":"validation","validationCode":"from workflow.configs import EnvStrategy, ConfigLoader\nstrategy = (raw or \"\").strip().lower()\nif strategy not in (s.value for s in EnvStrategy):\n    raise ValueError(f\"strategy must be one of {[s.value for s in EnvStrategy]}\")","typeGuard":null,"tryCatchPattern":"try:\n    loader = ConfigLoader.create(strategy)\nexcept ValueError as e:\n    logger.error(\"config loader strategy invalid: %s\", e)\n    raise SystemExit(2)","preventionTips":["Keep strategy values sourced from EnvStrategy enum, never free strings","Normalize case/whitespace on env-derived strategy values","Document accepted values next to the deployment config template","Fail fast at startup with the list of valid strategies"],"tags":["configuration","factory","startup"],"backgroundTag":"invalid-enum-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}