Fix smoke-test JSONC parsing to respect URLs
Validate / docs-check (push) Successful in 20s
Validate / validate-base (push) Successful in 13m50s
Validate / validate-omos (push) Successful in 14m37s
Publish Docker Image / smoke-base (push) Successful in 12m14s
Publish Docker Image / smoke-omos (push) Successful in 12m52s
Publish Docker Image / build-base (push) Successful in 43m6s
Publish Docker Image / build-omos (push) Successful in 45m45s
Publish Docker Image / update-description (push) Successful in 13s
Validate / docs-check (push) Successful in 20s
Validate / validate-base (push) Successful in 13m50s
Validate / validate-omos (push) Successful in 14m37s
Publish Docker Image / smoke-base (push) Successful in 12m14s
Publish Docker Image / smoke-omos (push) Successful in 12m52s
Publish Docker Image / build-base (push) Successful in 43m6s
Publish Docker Image / build-omos (push) Successful in 45m45s
Publish Docker Image / update-description (push) Successful in 13s
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.
This commit is contained in:
@@ -175,11 +175,14 @@ if docker run --rm \
|
|||||||
python3 /usr/local/lib/opencode-devbox/generate-config.py 2>/dev/null
|
python3 /usr/local/lib/opencode-devbox/generate-config.py 2>/dev/null
|
||||||
cat /tmp/home/.config/opencode/opencode.jsonc
|
cat /tmp/home/.config/opencode/opencode.jsonc
|
||||||
' > "$tmp/out.jsonc" 2>/dev/null; then
|
' > "$tmp/out.jsonc" 2>/dev/null; then
|
||||||
# Strip single-line // comments for JSON validation
|
# Strip single-line // comments for JSON validation (respecting strings)
|
||||||
sed 's|//.*$||' "$tmp/out.jsonc" > "$tmp/out.json"
|
|
||||||
if python3 -c "
|
if python3 -c "
|
||||||
import json, sys
|
import re, json, sys
|
||||||
c = json.load(open('$tmp/out.json'))
|
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['model'].startswith('anthropic/'), c
|
||||||
assert c['autoupdate'] is False
|
assert c['autoupdate'] is False
|
||||||
assert c['share'] == 'disabled'
|
assert c['share'] == 'disabled'
|
||||||
|
|||||||
Reference in New Issue
Block a user