From a803fe46532e23f0de4f7b8e428ad0a8511ccd12 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Sun, 3 May 2026 10:34:16 +0200 Subject: [PATCH] Fix smoke-test JSONC parsing to respect URLs The previous 'sed "s|//.*$||"' approach greedily stripped '//' from URLs like https://mcp.context7.com/mcp, corrupting the JSON and causing smoke-test failures with json.decoder.JSONDecodeError. Replaced the sed step with a Python regex that respects string literals so URLs pass through while only line comments are removed. --- scripts/smoke-test.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.sh index da93c7b..a4155eb 100755 --- a/scripts/smoke-test.sh +++ b/scripts/smoke-test.sh @@ -175,11 +175,14 @@ if docker run --rm \ python3 /usr/local/lib/opencode-devbox/generate-config.py 2>/dev/null cat /tmp/home/.config/opencode/opencode.jsonc ' > "$tmp/out.jsonc" 2>/dev/null; then - # Strip single-line // comments for JSON validation - sed 's|//.*$||' "$tmp/out.jsonc" > "$tmp/out.json" + # Strip single-line // comments for JSON validation (respecting strings) if python3 -c " -import json, sys -c = json.load(open('$tmp/out.json')) +import re, json, sys +text = open('$tmp/out.jsonc').read() +# Match either a string literal or a // comment; keep strings, drop comments +pattern = r'\"(?:\\\\.|[^\"\\\\])*\"|//[^\n]*' +stripped = re.sub(pattern, lambda m: m.group(0) if m.group(0).startswith('\"') else '', text) +c = json.loads(stripped) assert c['model'].startswith('anthropic/'), c assert c['autoupdate'] is False assert c['share'] == 'disabled'