{"record":{"id":"9992fa9e65872a02","repo":"iflytek/astron-agent","slug":"mockauditapi-know-ref-is-not-implemented-yet","errorCode":null,"errorMessage":"MockAuditAPI.know_ref is not implemented yet","messagePattern":"MockAuditAPI\\.know_ref 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":272,"sourceCode":"        :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":254,"sourceCodeEnd":273,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py#L254-L273","documentation":"MockAuditAPI.know_ref is a stub for the `/audit/v3/aichat/knowRef` endpoint (knowledge-reference screening in LLM content-security scenarios). It raises NotImplementedError because the mock implementation was never written. Any audit flow that routes knowledge-reference checks through the mock client fails immediately.","triggerScenarios":"Calling `await MockAuditAPI().know_ref(text, **kwargs)` — typically when the LLM response content-security pipeline checks referenced websites/knowledge bases while the mock audit API is the configured client.","commonSituations":"Local dev or test environments that default to the mock audit API; enabling a security policy that includes know_ref screening without switching to the real audit service; a newly added audit step not yet mirrored in the mock.","solutions":["Configure the real audit API client for this environment instead of the mock","Implement know_ref in MockAuditAPI mirroring the real client's contract (e.g. log-and-pass-through no-op)","Disable or skip the know_ref audit step when the mock client is in use"],"exampleFix":"// before (mock_audit_api.py)\nasync def know_ref(self, text: str, **kwargs: Any) -> None:\n    # path = f\"/audit/v3/aichat/knowRef\"\n    # TODO: To be implemented\n    raise NotImplementedError(\"MockAuditAPI.know_ref is not implemented yet\")\n\n// after\nasync def know_ref(self, text: str, **kwargs: Any) -> None:\n    logger.info(\"mock know_ref 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) and know_ref_required:\n    raise RuntimeError(\"know_ref screening requires the real audit API, not MockAuditAPI\")","typeGuard":"def supports_know_ref(api) -> bool:\n    impl = getattr(type(api), \"know_ref\", None)\n    return impl is not None and not getattr(impl, \"_is_stub\", False)","tryCatchPattern":"try:\n    await audit_api.know_ref(text)\nexcept NotImplementedError:\n    logger.warning(\"know_ref not implemented by %s; skipping knowledge-ref audit\", type(audit_api).__name__)","preventionTips":["Use the real audit service client wherever know_ref policies are enabled","Audit security-policy config against the mock's implemented surface before enabling","Cover the know_ref path in CI so stubs surface as test failures, not runtime errors"],"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"}