{"record":{"id":"27a8fce4e67851b9","repo":"iflytek/astron-agent","slug":"audit-input-error-result-abnormal-resp","errorCode":"AUDIT_INPUT_ERROR","errorMessage":"Audit result abnormal: {resp}","messagePattern":"Audit result abnormal: (.+?)","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py","lineNumber":181,"sourceCode":"\n        payload_context_list = []\n        payload_resource_list = []\n        if context_list:\n            for ctx in context_list:\n                if ctx.resource_list:\n                    payload_resource_list.append(\n                        res.dict() for res in ctx.resource_list\n                    )\n                payload_context_list.append(ctx.dict())\n\n        if payload_context_list:\n            payload[\"context_list\"] = payload_context_list\n        if payload_resource_list:\n            payload[\"resource_list\"] = payload_resource_list\n\n        resp = await self._post(\"/audit/v3/aichat/input\", payload, chat_app_id, uid)\n        if resp.get(\"data\", {}).get(\"action\") != ActionEnum.NONE:\n            raise CustomException(\n                CodeEnum.AUDIT_INPUT_ERROR,\n                cause_error=f\"Audit result abnormal: {resp}\",\n            )\n\n    async def output_text(\n        self,\n        stage: Stage,\n        content: str,\n        pindex: int,\n        span: Span,\n        is_pending: Literal[0, 1],\n        is_stage_end: Literal[0, 1],\n        is_end: Literal[0, 1],\n        chat_sid: str,\n        chat_app_id: str = \"\",\n        uid: str = \"\",\n        **kwargs: Any,\n    ) -> None:","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py#L163-L199","documentation":"MockAuditAPI.input_text raises CustomException(CodeEnum.AUDIT_INPUT_ERROR, 'Audit result abnormal: {resp}') when the mock audit service response for user input text (/audit/v3/aichat/input) returns data.action != ActionEnum.NONE. In this API, action NONE means 'content passed'; any other action (block/review/replace) is treated as an abnormal audit result and surfaces as this error. The message embeds the full response for diagnosis.","triggerScenarios":"Calling MockAuditAPI.input_text(content, chat_sid, span, ...) with content (or context_list history) that the audit backend flags: the mocked/simulated backend returns data.action other than NONE, e.g. action=block for sensitive user input.","commonSituations":"Users submit policy-violating prompts (politics, pornography, sensitive words) in a chat whose audit backend — even the mock — flags the input; a misconfigured audit template_id maps benign text to a blocking policy; the mock upstream service is configured to always return a non-NONE action, breaking every request.","solutions":["Inspect the embedded resp in the error message (and the logged response) to see data.action and the reason; fix the offending content or policy that triggered the block.","If the content is legitimate, review the audit template/policy configuration (template_id, app policy) that classified it as unsafe.","Verify the mock/audit backend configuration: if the simulated service is set to always return a non-NONE action, correct it to return ActionEnum.NONE for passing content.","Handle CustomException with code AUDIT_INPUT_ERROR in the chat entrypoint and return a friendly 'content violates policy' response to the user instead of a 500."],"exampleFix":"# before\nawait audit_api.input_text(user_input, chat_sid, span)\n\n# after\ntry:\n    await audit_api.input_text(user_input, chat_sid, span)\nexcept CustomException as e:\n    if e.code == CodeEnum.AUDIT_INPUT_ERROR:\n        return policy_violation_response(e)\n    raise","handlingStrategy":"try-catch","validationCode":"if contains_sensitive_terms(user_input) or not user_input.strip():\n    return pre_rejected_policy_response()","typeGuard":"def audit_passed(resp: dict) -> bool:\n    return isinstance(resp, dict) and resp.get(\"data\", {}).get(\"action\") == ActionEnum.NONE","tryCatchPattern":"try:\n    await audit_api.input_text(content, chat_sid, span, chat_app_id=app_id, uid=uid)\nexcept CustomException as e:\n    if e.code == CodeEnum.AUDIT_INPUT_ERROR:\n        logger.warning(\"Input audit rejected: %s\", e.cause_error)\n        return policy_violation_response()\n    raise","preventionTips":["Always catch CustomException by CodeEnum at chat entrypoints and return a friendly moderation message","Log the full audit response to identify which policy/action blocked the input","Keep audit template/policy configuration under review to avoid over-blocking legitimate input","Sanitize or prescreen user input before submission in test environments with strict mock policies"],"tags":["python","audit","content-moderation","custom-exception","input-validation"],"backgroundTag":"api-error-response","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"}