diff --git a/scripts/merge-json.py b/scripts/merge-json.py index febf64c..1d98c21 100644 --- a/scripts/merge-json.py +++ b/scripts/merge-json.py @@ -21,7 +21,8 @@ def merged_text(src_text, dest): existing = json.load(f) if not isinstance(existing, dict): raise ValueError("top level is not a JSON object") - before = json.dumps(existing, indent=2, ensure_ascii=False) + # json.load accepts NaN and Infinity, which are not valid JSON. + before = json.dumps(existing, indent=2, ensure_ascii=False, allow_nan=False) after = json.dumps(merge(existing, json.loads(src_text)), indent=2, ensure_ascii=False) return None if after == before else after + "\n" diff --git a/tests/test-install.sh b/tests/test-install.sh index 6cfa7d3..3b08809 100755 --- a/tests/test-install.sh +++ b/tests/test-install.sh @@ -147,7 +147,7 @@ else fail "a second run changed the merged settings" fi -for invalid in '{"model": "opus",' '["not an object"]' ''; do +for invalid in '{"model": "opus",' '["not an object"]' '{"x": NaN}' ''; do BAD_HOME="$(new_home)" BAD="$BAD_HOME/.claude/settings.json" printf '%s' "$invalid" > "$BAD"