-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error messages when parsing integers beyond the 64-bit range (#…
- Loading branch information
Showing
9 changed files
with
137 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4 | ||
core https://github.com/sourcemeta/core 524815a71cf4941eb5f3bd13729cbd78c28469f6 | ||
core https://github.com/sourcemeta/core 5a3472c3b0102da83bb4a191cea743511b871a7a | ||
hydra https://github.com/sourcemeta/hydra a67b879df800e834ed8a2d056f98398f7211d870 | ||
jsonbinpack https://github.com/sourcemeta/jsonbinpack c7bb7f4d903c3b6925b62ce2bb5b8d360e01ce84 | ||
blaze https://github.com/sourcemeta/blaze bf456d47dfd7fc51f077da268412735b4c6f9fa7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://example.com", | ||
"$ref": "nested" | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/invalid.json" | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://example.com/nested", | ||
"type": "integer", | ||
"exclusiveMaximum": 9223372036854776000 | ||
} | ||
EOF | ||
|
||
"$1" bundle "$TMP/schema.json" \ | ||
--resolve "$TMP/invalid.json" --verbose 2>"$TMP/stderr.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
error: The JSON value is not representable by the IETF RFC 8259 interoperable signed integer range at line 5 and column 23 | ||
$(realpath "$TMP")/invalid.json | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "integer", | ||
"maximum": 9223372036854776000 | ||
} | ||
EOF | ||
|
||
"$1" lint "$TMP/schema.json" >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
error: The JSON value is not representable by the IETF RFC 8259 interoperable signed integer range at line 4 and column 14 | ||
$(realpath "$TMP")/schema.json | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object" | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.jsonl" | ||
{ "foo": 1 } | ||
{ "foo": 9223372036854776000 } | ||
{ "foo": 3 } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" 2>"$TMP/stderr.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
error: The JSON value is not representable by the IETF RFC 8259 interoperable signed integer range at line 2 and column 10 | ||
$(realpath "$TMP")/instance.jsonl | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 27 additions & 5 deletions
32
vendor/core/src/core/json/include/sourcemeta/core/json_error.h
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.