{"record":{"id":"242408afc11f5436","repo":"iflytek/astron-agent","slug":"unsupported-content-type-for-input-review","errorCode":null,"errorMessage":"Unsupported content type for input review","messagePattern":"Unsupported content type for input review","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/audit_system/strategy/text_strategy.py","lineNumber":47,"sourceCode":"        :param input_frame: Input frame containing text content to be audited\n        :param span: Span object for tracking request context information\n        :return: None\n        \"\"\"\n        # Text content audit\n        if input_frame.content_type == ContentType.TEXT:\n            for audit_api in self.audit_apis:\n                # Call audit API for content review\n                await audit_api.input_text(\n                    content=input_frame.content,\n                    chat_sid=self.context.chat_sid,\n                    span=span,\n                    chat_app_id=self.context.chat_app_id,\n                    uid=self.context.uid,\n                    template_id=self.context.template_id,\n                    context_list=input_frame.context_list,\n                )\n        else:\n            raise ValueError(\"Unsupported content type for input review\")\n\n    async def output_review(self, output_frame: OutputFrameAudit, span: Span) -> None:\n        \"\"\"\n        Text output review logic, divided into first sentence audit and sentence-by-sentence audit.\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\n        if not self.context.last_content_stage:\n            self.context.last_content_stage = output_frame.stage\n\n        if self.context.last_content_stage == output_frame.stage:\n            self.context.remaining_content += output_frame.content\n\n        self.context.add_source_content(output_frame)\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/strategy/text_strategy.py#L29-L65","documentation":"TextStrategy.input_review dispatches on the input frame's content type and only supports the content types it explicitly handles (text-like inputs). When the frame's content type matches none of the known branches, it raises ValueError('Unsupported content type for input review'). The library throws this to signal that the selected strategy cannot audit that input content type.","triggerScenarios":"An InputFrameAudit whose content type is not one of the branches handled by TextStrategy reaches TextStrategy.input_review — e.g. an image/audio/media frame routed to the text strategy, or a new content type added upstream without updating the strategy's dispatch chain.","commonSituations":"Strategy-selection code maps a content type to TextStrategy by default/fallthrough; a new InputFrame content type was introduced elsewhere in the audit system without extending TextStrategy's if/elif chain; a misconfigured pipeline assigns frames of the wrong modality to the text strategy.","solutions":["Fix strategy selection so non-text frames are routed to a strategy that supports their content type","Add an elif branch (or handler) for the new content type in TextStrategy.input_review if the text strategy should handle it","Log the actual content_type value in the exception message to speed up diagnosis","Add an explicit allowlist check of supported content types before dispatch"],"exampleFix":"// before (text_strategy.py)\n        else:\n            raise ValueError(\"Unsupported content type for input review\")\n\n// after\n        else:\n            raise ValueError(\n                f\"Unsupported content type for input review: {input_frame.content_type!r}\"\n            )","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"text\", \"rich_text\"}  # content types TextStrategy.input_review handles\nif input_frame.content_type not in SUPPORTED:\n    raise ValueError(f\"TextStrategy cannot review content_type={input_frame.content_type!r}\")","typeGuard":"def is_text_frame(frame) -> bool:\n    return getattr(frame, \"content_type\", None) in (\"text\", \"rich_text\")","tryCatchPattern":"try:\n    await strategy.input_review(input_frame, span)\nexcept ValueError as e:\n    if \"Unsupported content type\" in str(e):\n        logger.error(\"content_type=%s misrouted to %s\", input_frame.content_type, type(strategy).__name__)\n    raise","preventionTips":["Select strategies via an explicit content_type -> strategy mapping, not default fallthrough","When adding a new frame content type upstream, update every strategy's dispatch and its tests","Include the offending content_type value in the error message","Add unit tests covering each content type through strategy selection"],"tags":["python","audit","valueerror","content-type","strategy-pattern"],"backgroundTag":"unsupported-enum-value","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"}