{"record":{"id":"071a4bc1f329b89b","repo":"run-llama/llama_index","slug":"the-enum-value-self-is-not-compatible-with-compo-071a4b","errorCode":null,"errorMessage":"The enum value {self} is not compatible with component of type {type(component)}","messagePattern":"The enum value (.+?) is not compatible with component of type (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/ingestion/data_sources.py","lineNumber":67,"sourceCode":"\n\nclass ConfigurableComponent(Enum):\n    @classmethod\n    def from_component(cls, component: BaseComponent) -> \"ConfigurableComponent\":\n        component_class = type(component)\n        for component_type in cls:\n            if component_type.value.component_type == component_class:\n                return component_type\n        raise ValueError(\n            f\"Component {component} is not a supported data source component.\"\n        )\n\n    def build_configured_data_source(\n        self, component: BaseComponent, name: Optional[str] = None\n    ) -> \"ConfiguredDataSource\":\n        component_type = self.value.component_type\n        if not isinstance(component, component_type):\n            raise ValueError(\n                f\"The enum value {self} is not compatible with component of \"\n                f\"type {type(component)}\"\n            )\n        elif isinstance(component, BasePydanticReader):\n            reader_config = ReaderConfig(reader=component)\n            return ConfiguredDataSource[ReaderConfig](component=reader_config)  # type: ignore\n\n        if isinstance(component, DocumentGroup) and name is None:\n            # if the component is a DocumentGroup, we want to use the\n            # full file path as the name of the data source\n            component = cast(DocumentGroup, component)\n            name = component.file_path\n\n        if name is None:\n            suffix = uuid.uuid1()\n            name = self.value.name + f\" [{suffix}]\"\n        return ConfiguredDataSource[component_type](  # type: ignore\n            component=component, name=name","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/ingestion/data_sources.py#L49-L85","documentation":"Thrown by build_configured_data_source() when the enum member's registered component_type does not match the component instance passed in. The isinstance guard ensures the produced ConfiguredDataSource is generic over the right component config type. It is the data-source counterpart of the data-sink compatibility check.","triggerScenarios":"Calling a specific enum member's build_configured_data_source() with a reader of a different type, e.g. member for SimpleDirectoryReader given a DatabaseReader; mixing a member obtained from one reader with an instance of another in cached/hard-coded workflow code.","commonSituations":"Hard-coded enum members in saved workflow configurations that break when the reader is swapped; test fixtures reusing members across different readers.","solutions":["Derive the member with ConfigurableComponent.from_component(component) instead of hard-coding it.","Guard with isinstance(component, member.value.component_type) before calling build_configured_data_source().","Re-generate persisted workflow configs after changing readers."],"exampleFix":"# before\nsource = ConfigurableComponent.SIMPLE_DIRECTORY.build_configured_data_source(db_reader)  # raises\n\n# after\nmember = ConfigurableComponent.from_component(db_reader)\nsource = member.build_configured_data_source(db_reader)","handlingStrategy":"validation","validationCode":"if not isinstance(component, member.value.component_type):\n    member = ConfigurableComponent.from_component(component)","typeGuard":null,"tryCatchPattern":"try:\n    source = member.build_configured_data_source(component)\nexcept ValueError:\n    member = ConfigurableComponent.from_component(component)\n    source = member.build_configured_data_source(component)","preventionTips":["Derive members with from_component() at call time","Treat saved enum references as cache that must be invalidated on reader swaps"],"tags":["ingestion","readers","workflow","type-mismatch"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}