From 902316566ed383067052dde90d54575fd1a7e698 Mon Sep 17 00:00:00 2001 From: duffyduck Date: Mon, 20 Jul 2026 19:57:05 +0200 Subject: [PATCH] fix(satellite): .env-Parser schneidet Inline-Kommentare ab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nativer Start crashte an `SCAN_INTERVAL_SEC=300 # Hintergrund-Rescan-Intervall` (int('300 # ...') → ValueError), weil der .env-Parser den Wert ungekuerzt nahm. Jetzt: ungequotete Werte werden am ersten " #" (Whitespace+#) abgeschnitten, gequotete Werte bleiben unangetastet (auch mit # im Inhalt). Getestet. Co-Authored-By: Claude Opus 4.8 --- satellite/satellite.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/satellite/satellite.py b/satellite/satellite.py index ebd5c23..d3d70bb 100644 --- a/satellite/satellite.py +++ b/satellite/satellite.py @@ -66,8 +66,17 @@ def _load_dotenv() -> None: if key.startswith("export "): key = key[len("export "):].strip() val = val.strip() - if len(val) >= 2 and val[0] == val[-1] and val[0] in ("'", '"'): - val = val[1:-1] + if val[:1] in ("'", '"'): + # Gequotet: Inhalt bis zum schliessenden Quote, Rest (Kommentar) egal. + q = val[0] + end = val.find(q, 1) + val = val[1:end] if end != -1 else val[1:] + else: + # Ungequotet: Inline-Kommentar (Whitespace + #) abschneiden. + m = re.search(r"\s+#", val) + if m: + val = val[:m.start()] + val = val.strip() if key and key not in os.environ: os.environ[key] = val except Exception as exc: