{"record":{"id":"1126f33ecd5a162e","repo":"iflytek/astron-agent","slug":"mockauditapi-output-media-is-not-implemented-yet","errorCode":null,"errorMessage":"MockAuditAPI.output_media is not implemented yet","messagePattern":"MockAuditAPI\\.output_media is not implemented yet","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py","lineNumber":260,"sourceCode":"        :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\n        :param kwargs: Additional keyword arguments\n        :return: None\n        \"\"\"\n        # path = f\"/audit/v3/aichat/knowRef\"\n        # TODO: To be implemented\n        raise NotImplementedError(\"MockAuditAPI.know_ref is not implemented yet\")\n","sourceCodeStart":242,"sourceCodeEnd":273,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py#L242-L273","documentation":"MockAuditAPI is the mock/no-op implementation of the audit API client in the workflow service's audit system. Its output_media method is a stub for the `/audit/v3/aichat/outputMedia` endpoint that has not been implemented yet, so any call immediately raises NotImplementedError. The library throws it to fail loudly rather than silently skipping output-media moderation.","triggerScenarios":"Any code path calls `await MockAuditAPI().output_media(text, **kwargs)` — e.g. the audit pipeline processes an output/media frame while the audit client is configured to use the mock implementation instead of the real audit service client.","commonSituations":"Running the workflow service locally or in tests where the mock audit API is wired in via config, but the audit strategy still emits media/output-media audit calls; the real HTTP client exists but the mock was never finished (see the TODO and commented-out path).","solutions":["Switch the audit API configuration to the real audit service client instead of MockAuditAPI","Implement output_media in mock_audit_api.py following the pattern of other implemented mock methods (perform the same validation/no-op contract as the real client)","If media auditing is not needed in this environment, guard the call site so output_media is only invoked when the frame's content type requires it"],"exampleFix":"// before (mock_audit_api.py)\nasync def output_media(self, text: str, **kwargs: Any) -> None:\n    # path = f\"/audit/v3/aichat/outputMedia\"\n    # TODO: To be implemented\n    raise NotImplementedError(\"MockAuditAPI.output_media is not implemented yet\")\n\n// after\nasync def output_media(self, text: str, **kwargs: Any) -> None:\n    logger.info(\"mock output_media skipped: %s\", text)\n    return None","handlingStrategy":"try-catch","validationCode":"from infra.audit_system.audit_api.mock.mock_audit_api import MockAuditAPI\nif isinstance(audit_api, MockAuditAPI):\n    raise RuntimeError(\"output_media is unimplemented in MockAuditAPI; use the real audit client\")","typeGuard":"def supports_output_media(api) -> bool:\n    impl = getattr(type(api), \"output_media\", None)\n    return impl is not None and \"not implemented\" not in (impl.__doc__ or \"\")","tryCatchPattern":"try:\n    await audit_api.output_media(text)\nexcept NotImplementedError:\n    logger.warning(\"output_media not implemented by %s; skipping media audit\", type(audit_api).__name__)","preventionTips":["Do not wire MockAuditAPI into environments that exercise media/output auditing","Keep the mock's stubs in sync with the real client's interface; track TODOs","Add a startup check that fails fast if an unimplemented audit API method is reachable"],"tags":["python","audit","not-implemented","mock"],"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"}