{"record":{"id":"04222b1c9a8642eb","repo":"invoke-ai/InvokeAI","slug":"unexpected-model-config-type-type-config","errorCode":null,"errorMessage":"Unexpected model config type: {type(config)}.","messagePattern":"Unexpected model config type: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/flux.py","lineNumber":1528,"sourceCode":"\n        with accelerate.init_empty_weights():\n            model = InstantXControlNetFlux(flux_params, num_control_modes)\n\n        model.load_state_dict(sd, assign=True)\n        return model\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.Flux, type=ModelType.IPAdapter, format=ModelFormat.Checkpoint)\nclass FluxIpAdapterModel(ModelLoader):\n    \"\"\"Class to load FLUX IP-Adapter models.\"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, IPAdapter_Checkpoint_Config_Base):\n            raise ValueError(f\"Unexpected model config type: {type(config)}.\")\n\n        sd = load_file(Path(config.path))\n\n        params = infer_xlabs_ip_adapter_params_from_state_dict(sd)\n\n        with accelerate.init_empty_weights():\n            model = XlabsIpAdapterFlux(params=params)\n\n        model.load_xlabs_state_dict(sd, assign=True)\n        return model\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.Flux, type=ModelType.FluxRedux, format=ModelFormat.Checkpoint)\nclass FluxReduxModelLoader(ModelLoader):\n    \"\"\"Class to load FLUX Redux models.\"\"\"\n\n    def _load_model(\n        self,","sourceCodeStart":1510,"sourceCodeEnd":1546,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/flux.py#L1510-L1546","documentation":"The FLUX XLabs IP-Adapter loader's _load_model only accepts configs deriving from IPAdapter_Checkpoint_Config_Base. If some other config object reaches this loader (registry misconfiguration, wrong model type on the record, or passing a config manually), it raises ValueError naming the unexpected type.","triggerScenarios":"Calling this loader's _load_model directly, or a registry lookup routing a non-IP-Adapter FLUX config into the XLabs IP-Adapter loader class.","commonSituations":"Custom scripts feeding arbitrary AnyModelConfig objects into loaders; a model record whose type was mis-edited in the database; developing a new IP-Adapter config class that does not subclass IPAdapter_Checkpoint_Config_Base.","solutions":["Ensure the model record is imported/registered as an IP-Adapter (FLUX XLabs) so the correct config class is used.","Pass a config that subclasses IPAdapter_Checkpoint_Config_Base, not a generic main-model config.","Fix the registry wiring so the config routes to the loader matching its class."],"exampleFix":"// before\nmodel = XLabsFluxIPAdapterLoader()._load_model(some_main_config)\n// after\nif not isinstance(some_main_config, IPAdapter_Checkpoint_Config_Base):\n    raise TypeError(\"Expected an XLabs IP-Adapter checkpoint config\")\nmodel = XLabsFluxIPAdapterLoader()._load_model(some_main_config)","handlingStrategy":"type-guard","validationCode":"if not isinstance(config, IPAdapter_Checkpoint_Config_Base):\n    raise TypeError(f\"Expected XLabs IP-Adapter config, got {type(config).__name__}\")","typeGuard":"def is_xlabs_ip_adapter(config) -> bool:\n    return isinstance(config, IPAdapter_Checkpoint_Config_Base)","tryCatchPattern":"try:\n    model = loader._load_model(config, submodel_type)\nexcept ValueError as e:\n    if \"Unexpected model config type\" in str(e):\n        raise RuntimeError(\"Config routed to wrong loader; re-scan the model\") from e\n    raise","preventionTips":["Let the model scan assign config classes; don't construct configs by hand","Keep the loader registry mappings intact when customizing","Check the model's recorded type in Model Manager before calling loaders directly"],"tags":["type-check","ip-adapter","flux"],"backgroundTag":"wrong-config-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}