{"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/8321021c54d670126ce3b2969d5deb880b4b0c2a/src/llm/core/interface.py#L12-L48","documentation":"LLMProvider (base class) declares get_default_model() as abstract via a NotImplementedError raise. Any concrete provider that fails to override it will throw at call time with the provider's class name in the message.","triggerScenarios":"Subclassing an LLM provider (subclass of the base in src/llm/core/interface.py) without defining get_default_model, then calling code that queries the provider's default model.","commonSituations":"Writing a new provider integration (e.g. a custom OpenAI-compatible endpoint) and implementing generate but forgetting the model accessor; upgrading the SDK where the base interface gained this requirement.","solutions":["Implement get_default_model() returning a model name string on the provider subclass","Check which provider class name appears in the message and open its definition","If the provider cannot supply a model, return a sensible default like 'gpt-4o-mini'"],"exampleFix":"// before\nclass MyProvider(LLMProvider):\n    def generate(self, prompt): ...\n// after\nclass MyProvider(LLMProvider):\n    def get_default_model(self) -> str:\n        return 'gpt-4o-mini'\n    def generate(self, prompt): ...","handlingStrategy":"type-guard","validationCode":"if not isinstance(getattr(provider, 'get_default_model', None), types.MethodType):\n    raise TypeError(f'{type(provider).__name__} is missing get_default_model')","typeGuard":"def implements_default_model(p: object) -> bool:\n    return callable(getattr(p, 'get_default_model', None)) and \\\n           type(p).get_default_model is not LLMProvider.get_default_model","tryCatchPattern":"try:\n    model = provider.get_default_model()\nexcept NotImplementedError as e:\n    logger.error('provider %s does not implement get_default_model', type(provider).__name__)\n    model = 'gpt-4o-mini'  # safe fallback","preventionTips":["When adding a provider, implement every abstract method; run a quick smoke instantiation test","Consider @abstractmethod decorators so failures occur at class definition, not call time","Add a unit test asserting all registered providers override get_default_model"],"tags":["not-implemented","oop","llm","abstract-method"],"backgroundTag":"method-not-implemented","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}