-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
NaN float values fail in gRPC tests and in console.log #3990
Comments
Thank you for reporting this to us @hanlaur 🙇🏻 I just looked into it a little bit and it would appear indeed that we apply some JSON serialization over the second argument of the k6/js/modules/k6/grpc/client.go Line 360 in f76cb77
I assume the JSON marshalling treats |
Hi! I was looking into this since I have the same problem. First, I wanted to understand why a null value works for the single float but not for the array. It seems the "problem" is with the Lines 132 to 135 in 613b0ad
In this code, using the same Proto definition that @hanlaur shared, when we use this input: {"single_float":null,"array_float":[1, null]} The unmarshaling fails for the value in the array, but works for the single value, even though they are of the same type. I was about to open an issue in the protobuf library, but I just saw an issue explaining this intended behavior. So, after that unrelated rant, it seems that the problem is exactly as @oleiade mentioned 😂. I guess the best approach would be to:
I wouldn’t mind working on this... I assume this would need to be addressed in https://github.com/grafana/sobek, since that's what’s used to build the message, right? Thanks! |
Brief summary
I am trying to load test gRPC service where some inputs are arrays of floats and the arrays may contain
NaN
values.The
gRPC.Client().invoke
serialization fails due toNaN
value being incorrectly treated asnull
. Same applies to Infinity values.Error message from the gRPC invoke:
ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
Similar (possibly related) behavior is visible also with
console.log
when logging objects/arrays where NaN values get logged as null. Logging individual NaN values works fine.k6 version
k6 v0.54.0 (go1.23.1, darwin/amd64)
OS
MacOS 14.7
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Below is a simplified test demonstrating the behavior for both
gRPC.Client().invoke
andconsole.log
:test.js:
dummy.proto:
resulting log messages when executing test
Expected behaviour
NaN value in the payload should be properly encoded as NaN float in the gRPC call and should not cause error.
Actual behaviour
NaN value in the payload causes error:
ERRO[0000] GoError: unable to serialise request object to protocol buffer: proto: (line 1:39): invalid value for float type: null
The text was updated successfully, but these errors were encountered: