{"record":{"id":"a5299229f7178aa7","repo":"iflytek/astron-agent","slug":"unsupported-rag-type-ragtype","errorCode":null,"errorMessage":"Unsupported RAG type: {ragType}","messagePattern":"Unsupported RAG type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/knowledge/service/rag_strategy_factory.py","lineNumber":45,"sourceCode":"\n    @classmethod\n    def get_strategy(cls, ragType: str) -> RAGStrategy:  # pylint: disable=invalid-name\n        \"\"\"\n        Get the corresponding strategy instance based on ragType.\n\n        Args:\n            ragType: The RAG type identifier\n\n        Returns:\n            An instance of the corresponding RAG strategy\n\n        Raises:\n            ValueError: If the ragType is not supported\n            TypeError: If the strategy class is abstract and cannot be instantiated\n        \"\"\"\n        strategy_class = cls._strategies.get(ragType)\n        if not strategy_class:\n            raise ValueError(f\"Unsupported RAG type: {ragType}\")\n\n        # Check if the class is abstract\n        if inspect.isabstract(strategy_class):\n            abstract_methods = []\n            for name, method in inspect.getmembers(\n                strategy_class, predicate=inspect.ismethod\n            ):\n                if getattr(method, \"__isabstractmethod__\", False):\n                    abstract_methods.append(name)\n            raise TypeError(\n                f\"Cannot instantiate abstract class {strategy_class.__name__} \"\n                f\"with abstract methods: {', '.join(abstract_methods)}\"\n            )\n\n        return strategy_class()\n\n    @classmethod\n    def register_strategy(","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/service/rag_strategy_factory.py#L27-L63","documentation":"RagStrategyFactory.get_strategy() raises ValueError when the requested ragType has no registered strategy class in _strategies. This is the factory's guard against unknown/unregistered RAG backend identifiers.","triggerScenarios":"Calling RagStrategyFactory.get_strategy(\"SomeRag\") with a ragType string that was never registered via the factory's registration mechanism, or a typo'd/renamed backend key.","commonSituations":"Typo in configuration (e.g. \"sparkdesk-rag\" vs \"SparkDesk-RAG\" case mismatch); a new RAG backend used in config without registering its strategy class; backend key renamed after refactor.","solutions":["Use the exact registered ragType string (check RagStrategyFactory._strategies keys) in config","Register the strategy class via the factory's register method before calling get_strategy","Validate the ragType config value at startup against supported keys"],"exampleFix":"// before\nRAG_TYPE=sparkdesk\nstrategy = RagStrategyFactory.get_strategy(\"sparkdesk\")\n// after\nRAG_TYPE=SparkDesk-RAG\nstrategy = RagStrategyFactory.get_strategy(\"SparkDesk-RAG\")","handlingStrategy":"validation","validationCode":"SUPPORTED = set(RagStrategyFactory._strategies)\nif rag_type not in SUPPORTED:\n    raise ValueError(f\"ragType must be one of {SUPPORTED}, got {rag_type!r}\")","typeGuard":"def is_valid_rag_type(rag_type: object) -> bool:\n    return isinstance(rag_type, str) and rag_type in RagStrategyFactory._strategies","tryCatchPattern":"try:\n    strategy = RagStrategyFactory.get_strategy(rag_type)\nexcept ValueError as e:\n    logger.error(f\"Unknown RAG type configured: {e}\")\n    raise ConfigError(\"ragType not supported\") from e","preventionTips":["Validate ragType against factory keys at application startup","Keep backend keys in a shared enum/constants module to avoid typos","Watch string case: registration is exact-match"],"tags":["python","factory","rag","invalid-enum"],"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-19T12:17:13.211Z"}