Skip to content

Commit 1813722

Browse files
Erick KinneeErick Kinnee
authored andcommitted
fix(config): address autoreview findings on JSON5 docs and tests
- Remove numeric separator claim (not valid JSON5) - Remove 'None known' unsupported-syntax claim, document known limitations - Restructure scalar tests to exercise skipVal (resolve sibling after exotic value) - Remove numeric separator test
1 parent 8d32f49 commit 1813722

2 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/config/issue-location.test.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,23 @@ describe("resolveConfigIssueLineInRaw", () => {
105105
});
106106

107107
it("handles hex numbers as values", () => {
108-
const raw = ["{", ' "a": 0x1A', "}"].join("\n");
109-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
108+
const raw = ["{", ' "a": 0x1A,', ' "b": 1', "}"].join("\n");
109+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(3);
110110
});
111111

112112
it("handles leading decimal numbers", () => {
113-
const raw = ["{", ' "a": .5', "}"].join("\n");
114-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
113+
const raw = ["{", ' "a": .5,', ' "b": 1', "}"].join("\n");
114+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(3);
115115
});
116116

117117
it("handles Infinity value", () => {
118-
const raw = ["{", ' "a": Infinity', "}"].join("\n");
119-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
118+
const raw = ["{", ' "a": Infinity,', ' "b": 1', "}"].join("\n");
119+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(3);
120120
});
121121

122122
it("handles NaN value", () => {
123-
const raw = ["{", ' "a": NaN', "}"].join("\n");
124-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
123+
const raw = ["{", ' "a": NaN,', ' "b": 1', "}"].join("\n");
124+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(3);
125125
});
126126

127127
it("handles null and boolean values", () => {
@@ -147,13 +147,13 @@ describe("resolveConfigIssueLineInRaw", () => {
147147
});
148148

149149
it("handles unicode escape sequences in strings", () => {
150-
const raw = ["{", ' "a": "hello \\u0041"', "}"].join("\n");
151-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
150+
const raw = ["{", ' "a": "hello \\u0041",', ' "b": 1', "}"].join("\n");
151+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(3);
152152
});
153153

154154
it("handles multi-line string continuation", () => {
155-
const raw = ["{", ' "a": "hello \\', 'world"', "}"].join("\n");
156-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
155+
const raw = ["{", ' "a": "hello \\', 'world",', ' "b": 1', "}"].join("\n");
156+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(4);
157157
});
158158

159159
it("handles unicode keys", () => {
@@ -162,13 +162,8 @@ describe("resolveConfigIssueLineInRaw", () => {
162162
});
163163

164164
it("handles escaped quotes in strings", () => {
165-
const raw = ["{", ' "a": "hello \\"world\\""', "}"].join("\n");
166-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
167-
});
168-
169-
it("handles numeric separators in values", () => {
170-
const raw = ["{", ' "a": 1_000', "}"].join("\n");
171-
expect(resolveConfigIssueLineInRaw(raw, ["a"])).toBe(2);
165+
const raw = ["{", ' "a": "hello \\"world\\"",', ' "b": 1', "}"].join("\n");
166+
expect(resolveConfigIssueLineInRaw(raw, ["b"])).toBe(3);
172167
});
173168

174169
it("handles block comments before keys", () => {

src/config/issue-location.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
// - Arrays: [value, ...] with bracket notation
77
// - Strings: double-quoted and single-quoted, with \n, \t, \", \', \\, \uXXXX,
88
// \xXX escape sequences, and multi-line (backslash-newline continuation)
9-
// - Numbers: integers, floats, hex (0x), leading decimal (.5), Infinity, NaN,
10-
// numeric separators (1_000)
9+
// - Numbers: integers, floats, hex (0x), leading decimal (.5), Infinity, NaN
1110
// - Comments: // line and /* block */
1211
// - Trailing commas in objects and arrays
1312
// - null, true, false literals
1413
//
1514
// The navigator only needs to find the byte offset of a value at a given path.
1615
// It does NOT need to fully parse every value — it skips over values using
1716
// skipVal/skipComposite. This means value-level syntax (hex numbers, special
18-
// values, numeric separators) is handled naturally by the value skipper.
17+
// values) is handled naturally by the value skipper.
1918
//
20-
// Unsupported syntax that would cause the navigator to fail gracefully
21-
// (returns undefined, no crash):
22-
// - None known — the navigator handles all JSON5 syntax that can appear in
23-
// OpenClaw config files. If a path cannot be resolved, the issue degrades
24-
// gracefully (no line number, no received value hint).
19+
// Known limitations (navigator fails gracefully, returns undefined):
20+
// - Unquoted keys with non-ASCII characters (Unicode letters outside A-Z, a-z,
21+
// _, $). Quoted Unicode keys ("café") work fine.
22+
// - The navigator's scalar skipper is permissive and may skip past text that
23+
// the canonical JSON5 parser would reject. This is safe because the navigator
24+
// only runs on configs that have already been successfully parsed.
2525
import path from "node:path";
2626
import { isSensitiveConfigPath } from "./sensitive-paths.js";
2727
import type { ConfigValidationIssue } from "./types.js";

0 commit comments

Comments
 (0)