{"record":{"id":"908da0cd612dc079","repo":"affaan-m/ECC","slug":"self-class-name-must-implement-get-defau","errorCode":null,"errorMessage":"{self.__class__.__name__} must implement get_default_model","messagePattern":"(.+?) must implement get_default_model","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"src/llm/core/interface.py","lineNumber":30,"sourceCode":"    provider_type: ProviderType\n\n    @abstractmethod\n    def generate(self, input: LLMInput) -> LLMOutput: ...\n\n    @abstractmethod\n    def list_models(self) -> list[ModelInfo]: ...\n\n    @abstractmethod\n    def validate_config(self) -> bool: ...\n\n    def supports_tools(self) -> bool:\n        return True\n\n    def supports_vision(self) -> bool:\n        return False\n\n    def get_default_model(self) -> str:\n        raise NotImplementedError(f\"{self.__class__.__name__} must implement get_default_model\")\n\n\nclass LLMError(Exception):\n    def __init__(\n        self,\n        message: str,\n        provider: ProviderType | None = None,\n        code: str | None = None,\n        details: dict[str, Any] | None = None,\n    ) -> None:\n        super().__init__(message)\n        self.message = message\n        self.provider = provider\n        self.code = code\n        self.details = details or {}\n\n\nclass AuthenticationError(LLMError): ...","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/src/llm/core/interface.py#L12-L48","documentation":"LLMProvider is an ABC with three abstractmethods (generate, list_models, validate_config) but get_default_model is a concrete method whose default body raises NotImplementedError. A subclass that fails to override get_default_model will instantiate fine (it is not abstract) but blow up at the first call.","triggerScenarios":"Subclassing LLMProvider (e.g. a new provider adapter) and forgetting to define get_default_model; calling provider.get_default_model() on a partially implemented provider; an old subclass predating the addition of get_default_model.","commonSituations":"Adding a new provider to the llm package without copying the get_default_model override pattern used by AstraflowProvider/AtlasProvider; a test fixture that subclasses the base without overriding every method.","solutions":["Override get_default_model in the subclass to return self.default_model (or whatever the provider's default is).","Alternatively, make get_default_model an @abstractmethod so the error surfaces at construction, not at call time.","Add a unit test that calls get_default_model() on every provider in the registry."],"exampleFix":"# before\nclass MyProvider(LLMProvider):\n    provider_type = ProviderType.MINE\n    def generate(self, llm_input): ...\n    def list_models(self): return []\n    def validate_config(self): return True\n\n# after\nclass MyProvider(LLMProvider):\n    provider_type = ProviderType.MINE\n    default_model = 'mine-1'\n    def generate(self, llm_input): ...\n    def list_models(self): return []\n    def validate_config(self): return True\n    def get_default_model(self) -> str:\n        return self.default_model","handlingStrategy":"type-guard","validationCode":"from llm.core.interface import LLMProvider\n\ndef assert_provider_complete(p: LLMProvider) -> None:\n    p.get_default_model()  # fail fast at construction/wire-up time","typeGuard":"from llm.core.interface import LLMProvider\n\ndef has_default_model(p: LLMProvider) -> bool:\n    try:\n        p.get_default_model()\n        return True\n    except NotImplementedError:\n        return False","tryCatchPattern":"try:\n    model = provider.get_default_model()\nexcept NotImplementedError:\n    model = 'fallback-model-id'","preventionTips":["Override get_default_model in every LLMProvider subclass, even if it just returns self.default_model.","Add a registry test that calls get_default_model() on every provider at import time.","Consider promoting get_default_model to an @abstractmethod so the error surfaces at construction, not at call time."],"tags":["abstraction","llm","provider","interface","subclassing"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}