{"record":{"id":"48af6c5a3e354563","repo":"OtterMind/Chat2DB","slug":"prepared-qq-notification-is-missing-or-too-large","errorCode":null,"errorMessage":"Prepared QQ notification is missing or too large","messagePattern":"Prepared QQ notification is missing or too large","errorType":"validation","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"script/github/notify_qq.py","lineNumber":247,"sourceCode":"        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\")\n    try:\n        envelope = json.loads(path.read_text(encoding=\"utf-8\"))\n    except (OSError, UnicodeError, json.JSONDecodeError) as error:\n        raise ConfigurationError(\"Prepared QQ notification is not valid JSON\") from error\n    if not isinstance(envelope, Mapping) or envelope.get(\"version\") != 1:\n        raise ConfigurationError(\"Prepared QQ notification has an invalid format\")\n    if envelope.get(\"repository\") != repository:\n        raise ConfigurationError(\"Prepared QQ notification repository does not match\")\n    event_name = str(envelope.get(\"event_name\") or \"\")\n    if event_name not in COLLECTED_EVENT_NAMES:\n        raise ConfigurationError(\"Prepared QQ notification event is not allowed\")\n    message = envelope.get(\"message\")\n    if not isinstance(message, str) or not message or len(message) > 900:\n        raise ConfigurationError(\"Prepared QQ notification message is invalid\")\n    if re.search(r\"[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]\", message):\n        raise ConfigurationError(\"Prepared QQ notification contains control characters\")\n    if re.search(r\"(?i)\\[CQ:\", message):\n        raise ConfigurationError(\"Prepared QQ notification contains a OneBot CQ code\")","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/script/github/notify_qq.py#L229-L265","documentation":"Thrown by notify_qq._read_prepared_message when the prepared-message file does not exist or its size exceeds 4096 bytes. The reader enforces a hard cap to avoid reading oversized/unbounded payloads from the relay drop location.","triggerScenarios":"The consumer step runs but the producer (_write_prepared_message) never wrote the file (wrong path/event skipped), or the written envelope exceeded 4 KB because the message payload was too large.","commonSituations":"Producer and consumer disagree on the file path; the producer was skipped due to an unsupported event (see error 336); a very long review body pushed the JSON over 4 KB; the file was cleaned up between steps.","solutions":["Ensure the producer step actually ran and wrote to the exact path the consumer reads.","Confirm the event is one of the three supported event names so the producer does not skip writing.","Truncate/summarize the message payload so the envelope stays under 4096 bytes."],"exampleFix":"# before: producer skipped event, consumer finds nothing\n_read_prepared_message(path, repo)\n# -> Prepared QQ notification is missing or too large\n\n# after: run producer only on supported events, matching path\nif event_name in COLLECTED_EVENT_NAMES:\n    _write_prepared_message(path, event_name, repo, msg)\n_read_prepared_message(path, repo)","handlingStrategy":"validation","validationCode":"if not path.is_file():\n    raise ConfigurationError(\"Producer did not write a file; check event support and path\")\nif path.stat().st_size > 4096:\n    raise ConfigurationError(\"Envelope exceeds 4 KB; truncate the message\")","typeGuard":null,"tryCatchPattern":"try:\n    event, msg = _read_prepared_message(path, repo)\nexcept ConfigurationError as e:\n    # log and skip rather than fail the whole workflow\n    print(f\"QQ notification skipped: {e}\", file=sys.stderr)\n    sys.exit(0)","preventionTips":["Ensure the producer runs on a supported event and writes the exact path.","Keep message payloads small (<4 KB envelope).","Use the same path constant for producer and consumer."],"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"}