OtterMind/Chat2DB · error · ConfigurationError

Prepared QQ notification event is not allowed

Error message

Prepared QQ notification event is not allowed

What it means

Raised by _read_prepared_message (notify_qq.py:258) when the envelope's "event_name" is not in COLLECTED_EVENT_NAMES (issue_comment, pull_request_review, pull_request_review_comment). Only those three events support the collect/prepare flow, so any other value is rejected to keep the relay payload bounded.

Source

Thrown at script/github/notify_qq.py:258

        ),
        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")
    return event_name, message


def _event_detail(event_name: str, action: str, payload: Mapping[str, Any]) -> str:
    if action in {"labeled", "unlabeled"}:
        label = payload.get("label") or {}
        return f"标签:{_clean_text(label.get('name'), 80)}"
    if action in {"assigned", "unassigned"}:
        return f"处理人:{_login(payload.get('assignee'))}"
    if action in {"milestoned", "demilestoned"}:
        milestone = payload.get("milestone") or {}

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Regenerate the envelope using a supported event (issue_comment, pull_request_review, or pull_request_review_comment).
  2. Discard the stale QQ_PREPARED_MESSAGE_PATH artifact and re-run the collect step with the current script.
  3. Send the notification live (without QQ_PREPARED_MESSAGE_PATH) if the event is not in the collect set.
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {"issue_comment", "pull_request_review", "pull_request_review_comment"}
event = str(envelope.get("event_name") or "")
if event not in ALLOWED:
    raise SystemExit(f"event {event!r} not collectable; send live instead")

Type guard

def is_collectable_event(envelope: object) -> bool:
    return isinstance(envelope, Mapping) and envelope.get("event_name") in {
        "issue_comment", "pull_request_review", "pull_request_review_comment"
    }

Prevention

When it happens

Trigger: An envelope carries an event_name outside the allowed set, e.g. "issues", "release", or a typo. This only occurs via the QQ_PREPARED_MESSAGE_PATH read path because the writer (_write_prepared_message) also validates event_name first.

Common situations: Hand-editing the prepared JSON; an envelope produced by an older/newer version of the script with a different allowed-event set; attempting to use the collect flow for an event that only supports live sending.

Related errors


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