{"record":{"id":"68c35ec680fdff22","repo":"iflytek/astron-agent","slug":"subclasses-must-implement-this-method","errorCode":null,"errorMessage":"Subclasses must implement this method","messagePattern":"Subclasses must implement this method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/audit_system/strategy/base_strategy.py","lineNumber":51,"sourceCode":"        :param chat_app_id: LLM application ID, passed through parameter for identifying the caller\n                           assigned by upstream to the LLM calling party\n        :param uid: User ID, passed through parameter for identifying specific users\n        \"\"\"\n        self.context = AuditContext(\n            chat_sid=chat_sid, template_id=template_id, chat_app_id=chat_app_id, uid=uid\n        )\n        self.audit_apis = audit_apis\n\n    @abstractmethod\n    async def input_review(self, input_frame: InputFrameAudit, span: Span) -> None:\n        \"\"\"\n        Input content review logic that subclasses must implement.\n\n        :param input_frame: Input frame containing content to be audited\n        :param span: Span object for tracking request context information\n        :return: None\n        \"\"\"\n        raise NotImplementedError(\"Subclasses must implement this method\")\n\n    @abstractmethod\n    async def output_review(self, output_frame: OutputFrameAudit, span: Span) -> None:\n        \"\"\"\n        Output content review logic that subclasses must implement.\n\n        :param output_frame: Output frame containing content to be audited\n        :param span: Span object for tracking request context information\n        :return: None\n        \"\"\"\n        raise NotImplementedError(\"Subclasses must implement this method\")\n","sourceCodeStart":33,"sourceCodeEnd":63,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/strategy/base_strategy.py#L33-L63","documentation":"BaseAuditStrategy.input_review is an abstract-style placeholder: the base class defines the input-review contract and requires every concrete strategy (e.g. TextStrategy) to override it. The base method only raises NotImplementedError. It surfaces when a subclass was added or instantiated without providing its own input_review implementation.","triggerScenarios":"A strategy class that inherits from BaseAuditStrategy but does not override input_review is registered/instantiated and the audit pipeline calls `strategy.input_review(input_frame, span)`.","commonSituations":"Adding a new audit strategy for a new content type and forgetting to implement input_review; partially refactored strategy classes; instantiating BaseAuditStrategy directly instead of a concrete subclass.","solutions":["Implement input_review in the concrete strategy subclass","Ensure the pipeline selects the correct concrete strategy for the frame's content type, not the base class","If using Python's abc, decorate input_review with @abstractmethod so missing implementations fail at instantiation time with a clearer TypeError"],"exampleFix":"// before (my_strategy.py)\nclass MyStrategy(BaseAuditStrategy):\n    pass\n\n// after\nclass MyStrategy(BaseAuditStrategy):\n    async def input_review(self, input_frame: InputFrameAudit, span: Span) -> None:\n        # dispatch review based on input_frame content type\n        ...","handlingStrategy":"type-guard","validationCode":"if type(strategy) is BaseAuditStrategy or not callable(getattr(type(strategy), \"input_review\", None)):\n    raise TypeError(f\"{type(strategy).__name__} must implement input_review\")","typeGuard":"def implements_input_review(strategy_cls) -> bool:\n    return (\n        strategy_cls is not BaseAuditStrategy\n        and \"input_review\" in strategy_cls.__dict__\n    )","tryCatchPattern":"try:\n    await strategy.input_review(input_frame, span)\nexcept NotImplementedError:\n    logger.error(\"strategy %s does not implement input_review\", type(strategy).__name__)\n    raise","preventionTips":["Inherit with @abstractmethod decorators so Python blocks incomplete subclasses at instantiation","Write a test asserting every registered strategy implements input_review and output_review","Never instantiate the base strategy directly"],"tags":["python","audit","abstract-method","strategy-pattern"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}