fix(satellite): .env-Parser schneidet Inline-Kommentare ab

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 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 19:57:05 +02:00
co-authored by Claude Opus 4.8
parent 1f94b4eab5
commit 902316566e
+11 -2
View File
@@ -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: