From 11db59d612265679cb212200b7421c50f6811529 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Mar 2026 10:55:40 +0000 Subject: [PATCH] fix: guard against non-dict route entries when filtering Caddy routes r.get() crashed when the Caddy API returned a routes array containing string elements. Added isinstance(r, dict) check and also made the match[0] traversal safer by using any() over the match list. --- builder/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builder/build.sh b/builder/build.sh index 9755600..069034e 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -132,7 +132,10 @@ EOF import sys, json routes = json.load(sys.stdin) new_host = '${APP_ID}.${DOMAIN_SUFFIX}' -routes = [r for r in routes if new_host not in r.get('match',[{}])[0].get('host',[])] +routes = [r for r in routes + if not (isinstance(r, dict) + and any(isinstance(m, dict) and new_host in m.get('host', []) + for m in r.get('match', [])))] routes.append(json.loads(sys.argv[1])) print(json.dumps(routes)) " "$ROUTE_JSON")