{"record":{"id":"f2e636e49569f460","repo":"iflytek/astron-agent","slug":"mockauditapi-input-media-is-not-implemented-yet","errorCode":null,"errorMessage":"MockAuditAPI.input_media is not implemented yet","messagePattern":"MockAuditAPI\\.input_media is not implemented yet","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"warning","filePath":"core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py","lineNumber":248,"sourceCode":"        logging.info(f\"\\nMockAuditAPI.output_text resp: {resp}\")\n        if resp.get(\"data\", {}).get(\"action\") != ActionEnum.NONE:\n            raise CustomException(\n                CodeEnum.AUDIT_OUTPUT_ERROR,\n                cause_error=f\"Audit result abnormal: {resp}\",\n            )\n\n    async def input_media(self, text: str, **kwargs: Any) -> None:\n        \"\"\"\n        In LLM content security scenarios, filter, detect and identify user input text,\n        images, videos, documents, etc., and process and respond accordingly based on security policies.\n        :param text: Text content to be processed\n        :param kwargs: Additional keyword arguments\n        :return: None\n        \"\"\"\n        # path = f\"/audit/v3/aichat/inputMedia\"\n\n        # TODO: To be implemented\n        raise NotImplementedError(\"MockAuditAPI.input_media is not implemented yet\")\n\n    async def output_media(self, text: str, **kwargs: Any) -> None:\n        \"\"\"\n        In LLM content security scenarios, filter, detect and identify LLM output images,\n        videos, audio, etc., and process and respond accordingly based on security policies.\n        :param text: Text content to be processed\n        :param kwargs: Additional keyword arguments\n        :return: None\n        \"\"\"\n        # path = f\"/audit/v3/aichat/outputMedia\"\n        # TODO: To be implemented\n        raise NotImplementedError(\"MockAuditAPI.output_media is not implemented yet\")\n\n    async def know_ref(self, text: str, **kwargs: Any) -> None:\n        \"\"\"\n        In LLM content security scenarios, filter, detect and identify websites, knowledge bases\n        and other data referenced during LLM responses, and process and respond accordingly based on security policies.\n        :param text: Text content to be processed","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py#L230-L266","documentation":"MockAuditAPI.input_media is an unimplemented stub for auditing user-submitted media (/audit/v3/aichat/inputMedia). The method only contains the commented endpoint path and a TODO, so every call raises NotImplementedError. It exists to fulfill the audit API interface; the mock backend never actually moderates input media.","triggerScenarios":"Any call to MockAuditAPI.input_media(text, **kwargs) — e.g. a workflow stage auditing user-uploaded images/videos/documents — regardless of arguments.","commonSituations":"A multimodal chat flow (user uploads an image) routes the input through the mock audit implementation in dev/test, hitting the stub; developers assume the mock covers all interface methods and only discover the gap at runtime; an interface sweep/conformance test enumerates audit methods and triggers it.","solutions":["Avoid calling input_media with MockAuditAPI; either skip media auditing in that environment or wire a backend that implements it.","Implement the stub: POST the payload to /audit/v3/aichat/inputMedia and raise CustomException(CodeEnum.AUDIT_INPUT_ERROR) when data.action != ActionEnum.NONE, mirroring input_text.","Add a capability flag on audit API implementations (e.g. supports_media_audit) and have the pipeline check it before calling media audit methods.","For a pure mock, make it a no-op return instead of raising so dev/test multimodal flows run end to end."],"exampleFix":"# before\nasync def input_media(self, text: str, **kwargs: Any) -> None:\n    # path = f\"/audit/v3/aichat/inputMedia\"\n    # TODO: To be implemented\n    raise NotImplementedError(\"MockAuditAPI.input_media is not implemented yet\")\n\n# after\nasync def input_media(self, text: str, **kwargs: Any) -> None:\n    payload = {\"intention\": \"dialog\", \"content\": text, **kwargs}\n    resp = await self._post(\"/audit/v3/aichat/inputMedia\", payload, kwargs.get(\"chat_app_id\", \"\"), kwargs.get(\"uid\", \"\"))\n    if resp.get(\"data\", {}).get(\"action\") != ActionEnum.NONE:\n        raise CustomException(CodeEnum.AUDIT_INPUT_ERROR, cause_error=f\"Audit result abnormal: {resp}\")","handlingStrategy":"fallback","validationCode":"if audit_backend == \"mock\" and content_type == \"media\":\n    logger.warning(\"MockAuditAPI does not implement input_media; skipping media audit\")\n    return","typeGuard":"def implements_input_media(api) -> bool:\n    import inspect\n    return \"raise NotImplementedError\" not in inspect.getsource(type(api).input_media)","tryCatchPattern":"try:\n    await audit_api.input_media(media_content)\nexcept NotImplementedError:\n    logger.warning(\"input_media unimplemented for %s; media passed unaudited\", type(audit_api).__name__)\nexcept CustomException as e:\n    handle_audit_rejection(e)","preventionTips":["In dev/test, treat mock media audit as pass-through rather than routing it through stub methods","Check implementation status of audit methods before enabling multimodal features","Prefer implementing stubs as explicit no-ops with warnings in mock backends so tests do not crash","Document which audit interface methods each backend implements and validate configuration against it at startup"],"tags":["python","audit","not-implemented","mock","multimodal"],"backgroundTag":"method-not-implemented","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}