{"record":{"id":"32c47dd2efdb69a6","repo":"Lightning-AI/pytorch-lightning","slug":"name-is-already-present-in-the-registry-hint-32c47d","errorCode":null,"errorMessage":"'{name}' is already present in the registry. HINT: Use `override=True`.","messagePattern":"'(.+?)' is already present in the registry\\. HINT: Use `override=True`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/registry.py","lineNumber":66,"sourceCode":"        description: Optional[str] = None,\n        override: bool = False,\n        **init_params: Any,\n    ) -> Callable:\n        \"\"\"Registers a strategy mapped to a name and with required metadata.\n\n        Args:\n            name : the name that identifies a strategy, e.g. \"deepspeed_stage_3\"\n            strategy : strategy class\n            description : strategy description\n            override : overrides the registered strategy, if True\n            init_params: parameters to initialize the strategy\n\n        \"\"\"\n        if not (name is None or isinstance(name, str)):\n            raise TypeError(f\"`name` must be a str, found {name}\")\n\n        if name in self and not override:\n            raise ValueError(f\"'{name}' is already present in the registry. HINT: Use `override=True`.\")\n\n        data: dict[str, Any] = {}\n        data[\"description\"] = description if description is not None else \"\"\n\n        data[\"init_params\"] = init_params\n\n        def do_register(strategy: Callable) -> Callable:\n            data[\"strategy\"] = strategy\n            data[\"strategy_name\"] = name\n            self[name] = data\n            return strategy\n\n        if strategy is not None:\n            return do_register(strategy)\n\n        return do_register\n\n    @override","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/registry.py#L48-L84","documentation":"StrategyRegistry.register refuses to silently overwrite an existing registration unless override=True. Registering a name that already exists (built-in names like 'ddp', 'xla', etc., or a duplicate custom registration) raises this ValueError.","triggerScenarios":"register('ddp', MyStrategy) when 'ddp' is already registered; registering the same custom strategy name twice, e.g. when a module is imported/reloaded or an extension runs twice.","commonSituations":"Plugins/extensions re-registering built-in strategy names; notebooks where cells re-execute registration code; library version upgrades adding a name a user had already registered.","solutions":["Choose a unique name not already in the registry (check registry.available_strategies())","If intentional replacement is desired, pass override=True: register('ddp', MyStrategy, override=True)","Guard registration: if 'my_strategy' not in registry: register(...)"],"exampleFix":"# before\nregister('ddp', MyStrategy)  # ValueError\n# after\nregister('ddp', MyStrategy, override=True)\n# or\nif 'ddp' not in registry:\n    register('ddp', MyStrategy)","handlingStrategy":"try-catch","validationCode":"if name in registry:\n    print(f'{name} already registered; skipping or overriding')","typeGuard":null,"tryCatchPattern":"try:\n    registry.register(name, strategy)\nexcept ValueError as e:\n    if 'already present' in str(e):\n        registry.register(name, strategy, override=True)\n    else:\n        raise","preventionTips":["Guard registrations with `if name not in registry`","Use override=True only when replacement is intentional"],"tags":["lightning","fabric","registry","duplicate-registration"],"backgroundTag":"duplicate-registry-entry","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}