{"record":{"id":"16b8ff6e9ef25fbf","repo":"Lightning-AI/pytorch-lightning","slug":"name-must-be-a-str-found-name-16b8ff","errorCode":null,"errorMessage":"`name` must be a str, found {name}","messagePattern":"`name` must be a str, found (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/registry.py","lineNumber":63,"sourceCode":"        self,\n        name: str,\n        strategy: Optional[Callable] = None,\n        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","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/registry.py#L45-L81","documentation":"StrategyRegistry.register validates that the registered strategy's `name` is a string (or None). Passing any non-str name (int, tuple, etc.) raises this TypeError immediately, before any registration occurs.","triggerScenarios":"Calling StrategyRegistry.register(name=123, strategy=...) or any non-string name; a custom plugin/extension registering strategies computed names of the wrong type.","commonSituations":"Third-party extensions or user scripts registering custom strategies with typos like name=('ddp', 'custom') or variables that evaluate to non-strings.","solutions":["Pass a plain string name: register('my_strategy', MyStrategy)","Coerce: register(str(name), ...) if the name comes from dynamic input"],"exampleFix":"# before\nregister(name=123, strategy=MyStrategy)\n# after\nregister(name='my_strategy', strategy=MyStrategy)","handlingStrategy":"type-guard","validationCode":"assert name is None or isinstance(name, str), f'name must be str, got {type(name)}'","typeGuard":"def is_valid_registry_name(name) -> bool:\n    return name is None or isinstance(name, str)","tryCatchPattern":null,"preventionTips":["Coerce dynamic names with str(name) before registering"],"tags":["lightning","fabric","registry","type-error"],"backgroundTag":"invalid-registry-name","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}