Skip to content
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

JSON Unmarshal fails if refID is an empty string. #1177

Open
asimpson opened this issue Dec 16, 2024 · 0 comments
Open

JSON Unmarshal fails if refID is an empty string. #1177

asimpson opened this issue Dec 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@asimpson
Copy link

asimpson commented Dec 16, 2024

What happened:
Queries that do not have a refID but instead have an empty string fail to unmarshal. This is most likely because jsoniter uses an empty string to denote the end of parsing which is problematic considering "" is a valid property name/key in JSON.

What you expected to happen:
Unmarshaling should work even if the refID is empty, encoding/json handles this case: https://play.golang.com/p/KhNyYGxA7eV

How to reproduce it (as minimally and precisely as possible):
I made and pushed a failing unit test here:

func TestQueryDataWithoutRefID(t *testing.T) {
qdr := backend.NewQueryDataResponse()
qdr.Responses[""] = testDataResponse()
b, err := json.Marshal(qdr)
require.NoError(t, err)
respCopy := &backend.QueryDataResponse{}
//Now unmarshall without a refId
err = json.Unmarshal(b, respCopy)
require.NoError(t, err)
}

@asimpson asimpson added the bug Something isn't working label Dec 16, 2024
@asimpson asimpson changed the title JSON Unmarshall fails if refID is an empty string. JSON Unmarshal fails if refID is an empty string. Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant