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

Extreme field value for 32-bit floating point field is returned with a too-large value #1203

Open
jskeet opened this issue Sep 6, 2022 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jskeet
Copy link
Contributor

jskeet commented Sep 6, 2022

We can exercise the maximum 32-bit floating point value like this:

curl -H "X-Goog-Api-Client: gapic/ rest/" 'http://localhost:7469/v1beta1/repeat:query?info.fFloat=3.40282346638528859811704183484516925440e%2B38'

The response includes (other fields trimmed):

"request":  {
    "info":  {
      "fFloat":  3.4028235e+38
    }
  }

This can't be parsed by the .NET protobuf parser, because 3.4028235e+38 is outside the range of a 32-bit floating point number.
(We parse the value as a 64-bit floating point number, then check whether the value is greater than the maximum 32-bit floating point number - which in this case it is.)

The proto3 JSON specification isn't entirely clear on how limits should be applied.

Is this a standard protobuf JSON formatter that's emitting this value?

@jskeet jskeet added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Sep 6, 2022
@jskeet
Copy link
Contributor Author

jskeet commented Sep 7, 2022

Looks like this is actually a .NET protobuf issue - see protocolbuffers/protobuf#10509.
(I'm looking into fixing that now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant