{"record":{"id":"6b545f9176f79058","repo":"invoke-ai/InvokeAI","slug":"more-than-one-model-matched-the-search-criteria-b","errorCode":null,"errorMessage":"More than one model matched the search criteria: base_model='{base_model}', model_type='{model_type}', model_name='{model_name}'.","messagePattern":"More than one model matched the search criteria: base_model='(.+?)', model_type='(.+?)', model_name='(.+?)'\\.","errorType":"exception","errorClass":"DuplicateModelException","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/model_records/model_records_base.py","lineNumber":300,"sourceCode":"\n        If none of the optional filters are passed, will return all\n        models in the database.\n        \"\"\"\n        pass\n\n    def all_models(self) -> List[AnyModelConfig]:\n        \"\"\"Return all the model configs in the database.\"\"\"\n        return self.search_by_attr()\n\n    def model_info_by_name(self, model_name: str, base_model: BaseModelType, model_type: ModelType) -> AnyModelConfig:\n        \"\"\"\n        Return information about a single model using its name, base type and model type.\n\n        If there are more than one model that match, raises a DuplicateModelException.\n        If no model matches, raises an UnknownModelException\n        \"\"\"\n        model_configs = self.search_by_attr(model_name=model_name, base_model=base_model, model_type=model_type)\n        if len(model_configs) > 1:\n            raise DuplicateModelException(\n                f\"More than one model matched the search criteria: base_model='{base_model}', model_type='{model_type}', model_name='{model_name}'.\"\n            )\n        if len(model_configs) == 0:\n            raise UnknownModelException(\n                f\"More than one model matched the search criteria: base_model='{base_model}', model_type='{model_type}', model_name='{model_name}'.\"\n            )\n        return model_configs[0]\n","sourceCodeStart":282,"sourceCodeEnd":309,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/model_records/model_records_base.py#L282-L309","documentation":"model_info_by_name looks up a model by name/base/type via search_by_attr and requires exactly one match. When more than one installed model config matches all three criteria it raises DuplicateModelException, because it cannot disambiguate which record to return.","triggerScenarios":"Calling model_info_by_name (or API endpoints using it) where two installed models share the same name, base_model and model_type — e.g. the same model installed twice from different paths/sources, or after a reinstall that didn't dedupe.","commonSituations":"Re-importing the same checkpoint from a new folder without deleting the old entry; scanning multiple model directories containing copies of the same file; merged/fine-tuned variants saved under an identical name in the same base/type.","solutions":["Call search_by_attr yourself, list the duplicate keys, and delete one via del_model.","Rename one of the duplicate models so names are unique.","Uninstall the stale/duplicate copy through the Model Manager UI.","Reference the model by its unique key instead of name where the API allows."],"exampleFix":"# before\ninfo = records.model_info_by_name('MyModel', BaseModelType.StableDiffusion1, ModelType.Main)\n# after\nconfigs = records.search_by_attr(model_name='MyModel', base_model=..., model_type=...)\nfor c in configs[1:]:\n    records.del_model(c.key)\ninfo = records.model_info_by_name('MyModel', BaseModelType.StableDiffusion1, ModelType.Main)","handlingStrategy":"try-catch","validationCode":"configs = records.search_by_attr(model_name=name, base_model=base, model_type=mtype)\nassert len(configs) <= 1, f\"Duplicates present: {[c.key for c in configs]}\"","typeGuard":null,"tryCatchPattern":"try:\n    info = records.model_info_by_name(name, base, mtype)\nexcept DuplicateModelException as e:\n    configs = records.search_by_attr(model_name=name, base_model=base, model_type=mtype)\n    info = min(configs, key=lambda c: c.key)  # or prompt user to disambiguate\n    log.warning('Duplicate models for %s; picking %s', name, info.key)","preventionTips":["Keep model names unique per base/type","Delete stale duplicates after re-installing models","Prefer referencing models by key, not name","Periodically scan for duplicates with search_by_attr"],"tags":["duplicate-model","model-records","lookup-ambiguity"],"backgroundTag":"duplicate-model-name","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}