{"record":{"id":"a02982662218fc3d","repo":"microsoft/autogen","slug":"expected-type-does-not-match","errorCode":null,"errorMessage":"Expected type does not match","messagePattern":"Expected type does not match","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/_component_config.py","lineNumber":301,"sourceCode":"            raise AttributeError(\"component_type not defined\")\n\n        loaded_config_version = loaded_model.component_version or component_class.component_version\n        if loaded_config_version < component_class.component_version:\n            try:\n                instance = component_class._from_config_past_version(loaded_model.config, loaded_config_version)  # type: ignore\n            except NotImplementedError as e:\n                raise NotImplementedError(\n                    f\"Tried to load component {component_class} which is on version {component_class.component_version} with a config on version {loaded_config_version} but _from_config_past_version is not implemented\"\n                ) from e\n        else:\n            schema = component_class.component_config_schema  # type: ignore\n            validated_config = schema.model_validate(loaded_model.config)\n\n            # We're allowed to use the private method here\n            instance = component_class._from_config(validated_config)  # type: ignore\n\n        if expected is None and not isinstance(instance, cls):\n            raise TypeError(\"Expected type does not match\")\n        elif expected is None:\n            return cast(Self, instance)\n        elif not isinstance(instance, expected):\n            raise TypeError(\"Expected type does not match\")\n        else:\n            return cast(ExpectedType, instance)\n\n\nclass ComponentSchemaType(Generic[ConfigT]):\n    # Ideally would be ClassVar[Type[ConfigT]], but this is disallowed https://github.com/python/typing/discussions/1424 (despite being valid in this context)\n    component_config_schema: Type[ConfigT]\n    \"\"\"The Pydantic model class which represents the configuration of the component.\"\"\"\n\n    required_class_vars = [\"component_config_schema\", \"component_type\"]\n\n    def __init_subclass__(cls, **kwargs: Any):\n        super().__init_subclass__(**kwargs)\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/_component_config.py#L283-L319","documentation":"Error \"Expected type does not match\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-core/src/autogen_core/_component_config.py:301 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the component_type in the config matches the class loading it"],"exampleFix":"Align provider/component_type in the config with the target class","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}