{"record":{"id":"0b8b0a57653af567","repo":"OtterMind/Chat2DB","slug":"cannot-collect-unsupported-event-event-name","errorCode":null,"errorMessage":"Cannot collect unsupported event: {event_name}","messagePattern":"Cannot collect unsupported event: (.+?)","errorType":"validation","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"script/github/notify_qq.py","lineNumber":229,"sourceCode":"def _review_action_label(action: str, state: str) -> str:\n    if action == \"dismissed\":\n        return \"评审已撤销\"\n    if action == \"edited\":\n        return \"评审已编辑\"\n    if state == \"approved\":\n        return \"评审已批准\"\n    if state == \"changes_requested\":\n        return \"评审要求修改\"\n    if state == \"commented\":\n        return \"收到评审评论\"\n    return \"已提交评审\"\n\n\ndef _write_prepared_message(\n    path: Path, event_name: str, repository: str, message: str\n) -> None:\n    if event_name not in COLLECTED_EVENT_NAMES:\n        raise ConfigurationError(f\"Cannot collect unsupported event: {event_name}\")\n    path.parent.mkdir(parents=True, exist_ok=True)\n    path.write_text(\n        json.dumps(\n            {\n                \"version\": 1,\n                \"event_name\": event_name,\n                \"repository\": repository,\n                \"message\": message,\n            },\n            ensure_ascii=False,\n        ),\n        encoding=\"utf-8\",\n    )\n\n\ndef _read_prepared_message(path: Path, repository: str) -> tuple[str, str]:\n    if not path.is_file() or path.stat().st_size > 4096:\n        raise ConfigurationError(\"Prepared QQ notification is missing or too large\")","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/script/github/notify_qq.py#L211-L247","documentation":"Thrown by notify_qq._write_prepared_message when the GitHub event_name is not in COLLECTED_EVENT_NAMES. Only three events are collected for QQ relay: issue_comment, pull_request_review, and pull_request_review_comment. Any other event (or a typo) is rejected so the relay never persists an unsupported notification.","triggerScenarios":"The workflow/dispatcher calls _write_prepared_message with an event_name outside the allowed set - e.g. 'push', 'issues', 'pull_request' (the generic event, not the review), or a misspelled name.","commonSituations":"A GitHub Action configured to run this script on additional events (push, issues); a renamed/typo'd event; adding a new notification type without updating COLLECTED_EVENT_NAMES.","solutions":["Only invoke the script for issue_comment, pull_request_review, or pull_request_review_comment events.","In the workflow, gate the step with an if: condition on github.event_name membership.","To support a new event, add it to COLLECTED_EVENT_NAMES and implement its message builder."],"exampleFix":"# before (workflow)\non: [push, pull_request_review]\n# push -> Cannot collect unsupported event: push\n\n# after\non:\n  issue_comment:\n    types: [created]\n  pull_request_review:\n    types: [submitted]","handlingStrategy":"validation","validationCode":"COLLECTED_EVENT_NAMES = {\n    \"issue_comment\", \"pull_request_review\", \"pull_request_review_comment\",\n}\nif event_name not in COLLECTED_EVENT_NAMES:\n    raise ConfigurationError(f\"Skip unsupported event: {event_name}\")","typeGuard":"def is_collected_event(event_name: str) -> bool:\n    return event_name in {\n        \"issue_comment\", \"pull_request_review\", \"pull_request_review_comment\",\n    }","tryCatchPattern":null,"preventionTips":["Gate the workflow step on supported event names via an if: condition.","Only add new events by extending COLLECTED_EVENT_NAMES and the message builder.","Avoid typos by referencing the constant, not string literals."],"tags":["notify-qq","github-actions","python","validation","config"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}