Skip to content

invalid json file validated since v4.40.2 #2351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sda399 opened this issue Apr 30, 2025 · 4 comments
Open

invalid json file validated since v4.40.2 #2351

sda399 opened this issue Apr 30, 2025 · 4 comments
Labels

Comments

@sda399
Copy link

sda399 commented Apr 30, 2025

Describe the bug
hi folks
invalid json is parsed and fixed by yq, this breaks file validation tests based on yq

Version of yq: 4.40.2
Operating system: linux
Installed via: github binary

Input Json

{
  "hello": "value"
  "foo": "bar"
}

Command

for V in 4.35.1 4.40.2; do
  curl -L --silent --output /tmp/yq "https://github.com/mikefarah/yq/releases/download/v$V/yq_linux_amd64"
  chmod +x /tmp/yq
  echo "==="
  /tmp/yq --version
  echo '{"hello": "value"\n "foo": "bar"}' | /tmp/yq -e -pj -oj
  rm /tmp/yq
done

Actual behavior

{
  "hello": "value",
  "foo": "bar"
}

Expected behavior
expected an error on parsing

Error: bad file '-': invalid character '"' after object key:value pair
@mikefarah
Copy link
Owner

Oh interesting! The underlying json tokeniser I'm using (goccy/json) is responsible for that - feel free to raise an issue against that repo

@sda399
Copy link
Author

sda399 commented May 3, 2025

hum,
they seem to have a unit test for it.
https://github.com/goccy/go-json/blame/9872089c316cfe2d0f29b331b75d45bf6d522d96/json_test.go#L257

{`{"X": "foo" "Y": "bar"}`, json.NewSyntaxError("invalid character '\"' after object key:value pair", 13)},

@mikefarah
Copy link
Owner

Hmm I can see that that error message comes from their indenter code in their encoder...whereas the problem I'm having is in decoding 😕 I'll dig in some more

@mikefarah
Copy link
Owner

Ok I think I found the culprit, raised issue here: goccy/go-json#548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants