OtterMind/Chat2DB · error · ConfigurationError

Prepared QQ notification is missing or too large

Error message

Prepared QQ notification is missing or too large

What it means

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.

Source

Thrown at script/github/notify_qq.py:247

        raise ConfigurationError(f"Cannot collect unsupported event: {event_name}")
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(
        json.dumps(
            {
                "version": 1,
                "event_name": event_name,
                "repository": repository,
                "message": message,
            },
            ensure_ascii=False,
        ),
        encoding="utf-8",
    )


def _read_prepared_message(path: Path, repository: str) -> tuple[str, str]:
    if not path.is_file() or path.stat().st_size > 4096:
        raise ConfigurationError("Prepared QQ notification is missing or too large")
    try:
        envelope = json.loads(path.read_text(encoding="utf-8"))
    except (OSError, UnicodeError, json.JSONDecodeError) as error:
        raise ConfigurationError("Prepared QQ notification is not valid JSON") from error
    if not isinstance(envelope, Mapping) or envelope.get("version") != 1:
        raise ConfigurationError("Prepared QQ notification has an invalid format")
    if envelope.get("repository") != repository:
        raise ConfigurationError("Prepared QQ notification repository does not match")
    event_name = str(envelope.get("event_name") or "")
    if event_name not in COLLECTED_EVENT_NAMES:
        raise ConfigurationError("Prepared QQ notification event is not allowed")
    message = envelope.get("message")
    if not isinstance(message, str) or not message or len(message) > 900:
        raise ConfigurationError("Prepared QQ notification message is invalid")
    if re.search(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]", message):
        raise ConfigurationError("Prepared QQ notification contains control characters")
    if re.search(r"(?i)\[CQ:", message):
        raise ConfigurationError("Prepared QQ notification contains a OneBot CQ code")

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure the producer step actually ran and wrote to the exact path the consumer reads.
  2. Confirm the event is one of the three supported event names so the producer does not skip writing.
  3. Truncate/summarize the message payload so the envelope stays under 4096 bytes.

Example fix

# before: producer skipped event, consumer finds nothing
_read_prepared_message(path, repo)
# -> Prepared QQ notification is missing or too large

# after: run producer only on supported events, matching path
if event_name in COLLECTED_EVENT_NAMES:
    _write_prepared_message(path, event_name, repo, msg)
_read_prepared_message(path, repo)
Defensive patterns

Strategy: validation

Validate before calling

if not path.is_file():
    raise ConfigurationError("Producer did not write a file; check event support and path")
if path.stat().st_size > 4096:
    raise ConfigurationError("Envelope exceeds 4 KB; truncate the message")

Try / catch

try:
    event, msg = _read_prepared_message(path, repo)
except ConfigurationError as e:
    # log and skip rather than fail the whole workflow
    print(f"QQ notification skipped: {e}", file=sys.stderr)
    sys.exit(0)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/48af6c5a3e354563. Report an issue: GitHub.