iflytek/astron-agent · error · ValueError
Unsupported RAG type
Error message
Unsupported RAG type: {ragType} What it means
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.
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
Example fix
// before
RAG_TYPE=sparkdesk
strategy = RagStrategyFactory.get_strategy("sparkdesk")
// after
RAG_TYPE=SparkDesk-RAG
strategy = RagStrategyFactory.get_strategy("SparkDesk-RAG") Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = set(RagStrategyFactory._strategies)
if rag_type not in SUPPORTED:
raise ValueError(f"ragType must be one of {SUPPORTED}, got {rag_type!r}") Type guard
def is_valid_rag_type(rag_type: object) -> bool:
return isinstance(rag_type, str) and rag_type in RagStrategyFactory._strategies Try / catch
try:
strategy = RagStrategyFactory.get_strategy(rag_type)
except ValueError as e:
logger.error(f"Unknown RAG type configured: {e}")
raise ConfigError("ragType not supported") from e Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- (CustomException ErrorResponse)
- (ThirdPartyException ErrorResponse)
- IFlyAuditAPI.know_ref is not implemented yet
- Internal server error
- SparkDesk-RAG does not support chunks_delete operation.
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a5299229f7178aa7.
Report an issue: GitHub.
Appendix: source
Thrown at core/knowledge/service/rag_strategy_factory.py:45
@classmethod
def get_strategy(cls, ragType: str) -> RAGStrategy: # pylint: disable=invalid-name
"""
Get the corresponding strategy instance based on ragType.
Args:
ragType: The RAG type identifier
Returns:
An instance of the corresponding RAG strategy
Raises:
ValueError: If the ragType is not supported
TypeError: If the strategy class is abstract and cannot be instantiated
"""
strategy_class = cls._strategies.get(ragType)
if not strategy_class:
raise ValueError(f"Unsupported RAG type: {ragType}")
# Check if the class is abstract
if inspect.isabstract(strategy_class):
abstract_methods = []
for name, method in inspect.getmembers(
strategy_class, predicate=inspect.ismethod
):
if getattr(method, "__isabstractmethod__", False):
abstract_methods.append(name)
raise TypeError(
f"Cannot instantiate abstract class {strategy_class.__name__} "
f"with abstract methods: {', '.join(abstract_methods)}"
)
return strategy_class()
@classmethod
def register_strategy(View on GitHub (pinned to 5e758547a8)