OtterMind/Chat2DB · error · ConfigurationError

Prepared QQ notification contains control characters

Error message

Prepared QQ notification contains control characters

What it means

Raised by _read_prepared_message (notify_qq.py:263) when message contains a C0 control character or DEL (\x00-\x08, \x0b, \x0c, \x0e-\x1f, \x7f). OneBot/QQ group messages reject such bytes, and the live build path strips them via _clean_text, so the prepared envelope must already be clean.

Source

Thrown at script/github/notify_qq.py:263

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 {}
        return f"里程碑:{_clean_text(milestone.get('title'), 100)}"
    if action in {"review_requested", "review_request_removed"}:
        reviewer = _login(payload.get("requested_reviewer"))
        team = payload.get("requested_team") or {}
        target = reviewer or _clean_text(team.get("name"), 80)

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Regenerate the envelope through the collect step, which runs _clean_text on every field.
  2. Strip control characters from the message field: re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', '', message).
  3. Discard the tampered artifact and re-run collect.

Example fix

import re
clean = re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', '', message)
Defensive patterns

Strategy: validation

Validate before calling

import re
if re.search(r'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', message):
    message = re.sub(r'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', '', message)

Type guard

import re
CONTROL = re.compile(r'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]')
def is_clean_text(message: str) -> bool:
    return not CONTROL.search(message)

Prevention

When it happens

Trigger: The envelope's message contains a raw control byte, e.g. a literal NUL, BEL, or vertical tab. Only reachable via QQ_PREPARED_MESSAGE_PATH because the writer sanitizes with _clean_text.

Common situations: Hand-editing or piping a binary/templated message into the envelope; an envelope produced by tooling that did not sanitize; copy-paste from a terminal that embeds escape sequences.

Related errors


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