error fix

This commit is contained in:
2026-06-26 17:19:17 +02:00
parent d16b693aab
commit c5b4737342
+23 -13
View File
@@ -7,42 +7,52 @@ import sys
def main(): def main():
raw_json = os.environ.get("OPTIONS_B64_JSON", "[]").strip() raw_options = os.environ.get("OPTIONS_B64_JSON", "").strip()
if not raw_options:
print("FEHLER: OPTIONS_B64_JSON ist leer", file=sys.stderr)
sys.exit(1)
try: try:
options_b64 = json.loads(raw_json) options_b64 = json.loads(raw_options)
except json.JSONDecodeError as exc: except json.JSONDecodeError as exc:
print(f"FEHLER: OPTIONS_B64_JSON ist kein gültiges JSON: {exc}", file=sys.stderr) print("FEHLER: OPTIONS_B64_JSON ist kein gültiges JSON", file=sys.stderr)
print(str(exc), file=sys.stderr)
print("Rohwert:", raw_options, file=sys.stderr)
sys.exit(1) sys.exit(1)
options = [] options = []
for raw in options_b64: for index, raw in enumerate(options_b64, start=1):
if not raw:
continue
raw = str(raw).strip() raw = str(raw).strip()
if not raw: if not raw:
print(f"WARNUNG: Host-Ergebnis {index} ist leer")
continue continue
try: try:
decoded = base64.b64decode(raw).decode("utf-8") decoded = base64.b64decode(raw).decode("utf-8")
options.extend(json.loads(decoded)) decoded_options = json.loads(decoded)
if not isinstance(decoded_options, list):
print(f"WARNUNG: Host-Ergebnis {index} ist keine JSON-Liste")
continue
options.extend(decoded_options)
except Exception as exc: except Exception as exc:
print(f"WARNUNG: Ein Host-Ergebnis konnte nicht gelesen werden: {exc}", file=sys.stderr) print(f"WARNUNG: Host-Ergebnis {index} konnte nicht verarbeitet werden: {exc}", file=sys.stderr)
options = sorted(set(options)) options = sorted(set(options))
with open("select_options.json", "w", encoding="utf-8") as f: with open("select_options.json", "w", encoding="utf-8") as file:
json.dump(options, f, indent=2, ensure_ascii=False) json.dump(options, file, indent=2, ensure_ascii=False)
print("==========================================") print("==========================================")
print("Dropdown-Liste gebaut") print("Dropdown-Liste gebaut")
print(f"Dropdown-Optionen: {len(options)}") print(f"Dropdown-Optionen: {len(options)}")
print("==========================================") print("==========================================")
print("") print("")
print("Dropdown-Liste:")
print(json.dumps(options, indent=2, ensure_ascii=False)) print(json.dumps(options, indent=2, ensure_ascii=False))