From 0deb3a59ccc1f1688d6783b7398b443ca7f88b4b Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Sat, 15 Aug 2026 09:43:54 +0200 Subject: [PATCH] =?UTF-8?q?fix(P-073):=20crash=5Fforensics-Import=20im=20G?= =?UTF-8?q?ateway-Kontext=20=E2=80=94=20expliziter=20sys.path-Eintrag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der bare Import 'from crash_forensics import check_for_predecessor_crash' schlug im Gateway-Kontext fehl (ModuleNotFoundError), weil crash_forensics.py als Flat-Modul im Plugin-Verzeichnis liegt (Sibling von adapter.py, nicht in archivar/) und das Plugin-Verzeichnis nicht zuverlässig auf sys.path ist. Fix: expliziter sys.path-Eintrag des Plugin-Verzeichnisses vor dem Import (P-022/P-023-Muster). Zusätzlich except-Block von logger.debug auf logger.warning angehoben, damit Import-Fehler nicht mehr still geschluckt werden. --- plugin/adapter.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/adapter.py b/plugin/adapter.py index 6336b56..5be65fd 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -1669,13 +1669,24 @@ class RocketChatAdapter(BasePlatformAdapter): if not self._crash_forensic_done and not is_reconnect: self._crash_forensic_done = True try: + # P-073: crash_forensics liegt als Flat-Modul im Plugin-Verzeichnis + # (Sibling von adapter.py, NICHT in archivar/). Im Gateway-Kontext + # ist das Plugin-Verzeichnis nicht zuverlässig auf sys.path — der + # bare Import `from crash_forensics import ...` schlägt mit + # ModuleNotFoundError fehl (P-022/P-023-Muster). Expliziter + # sys.path-Eintrag stellt sicher, dass das Modul auffindbar ist. + import sys as _sys + import os as _os + _plugin_dir = _os.path.dirname(_os.path.abspath(__file__)) + if _plugin_dir not in _sys.path: + _sys.path.insert(0, _plugin_dir) from crash_forensics import check_for_predecessor_crash report = await check_for_predecessor_crash() if report: for line in report.splitlines(): logger.info(line) except Exception as _forensic_exc: - logger.debug( + logger.warning( "[rocketchat] Crash-Forensik fehlgeschlagen (nicht blockierend): %s", _forensic_exc, )