fix(P-073): crash_forensics-Import im Gateway-Kontext — expliziter sys.path-Eintrag

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.
This commit is contained in:
Bernd (Hermes)
2026-08-15 09:43:54 +02:00
parent 8dc62f1573
commit 0deb3a59cc
+12 -1
View File
@@ -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,
)