[BUG-12836] com.google.gson.internal.LazilyParsedNumber Type

Hi,
I am currently using the beta b2019011502.
On the “style classes” property of a Label component, I set an Expression Structure binding, as below.

The key-values pairs are:

  • the “allow” key has a constant custom property value.
  • the two keys “actual” and “target” have two tags values.

The script throws an exception with the following message:
*General Error: unsupported operand type(s) for : ‘float’ and 'com.google.gson.internal.LazilyParsedNumber

What is going on? Thank you.

After replicating your script I’m not encountering the same issue…

Next steps to help me troubleshoot:

  1. Are the self.view.custom.additionalInfo.thresholds.low/high properties bound to other values?
  2. Where exactly are you seeing this error message? Designer console? Browser console? Gateway logs?

First note: It looks like the script is attempting to operate on two different types of objects (a “float” and a “com.google.gson.internal.LazilyParsedNumber”). That com.google.gson.internal.LazilyParsedNumber should be digested into a usable value by the time it reaches you script.

Second note: “actual” and “target” are bound to properties, not tags. Even if the view.custom.actual and view.custom.target properties are bound to tags, I’m still not able to replicate the issue.

Third note: It’s very odd that there is no operand declared in the error message you’ve supplied - I would have expected < or >= or *… Could you double-check the error message and make sure there isn’t a character omitted from what you’ve posted?

1. Are the self.view.custom.additionalInfo.thresholds.low/high properties bound to other values?
No, they are constant values.
2. Where exactly are you seeing this error message? Designer console? Browser console? Gateway logs?
In the gateway logs.

I could try t replicate this error with the latest nightly build.
Thanks,
Andrea

While I don’t know that it’s necessary, you could also try wrapping your comparisons in parentheses to rule out a syntax error in the first elif:
a < b < c: should be okay, but (a < b) and (b < c): is definitely okay. A syntax error of this type could explain the “:” from your error message…

That error occurs because an operand used in a mathematical equation is of type lazilyparsednumber and not a normal numeric type. I can’t tell what line it is occurring from the error you provided and couldn’t reproduce on my machine. That said, judging by the fact that your binding preview is returning a value from inside the try block and not from the except block, how sure are you that the error is being caused by this script?

Regardless, there is an easy way to get the value you want out of a lazilyparsednumber which is sort of documented here: https://github.com/google/gson/blob/master/gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java

Basically, if you find out what variable is the lazilyparsednumber (lets say self.view.custom.additionalInfo.thresholds.low) and you want to get the float value out of it, you can use the floatValue() method like so: self.view.custom.additionalInfo.thresholds.low.floatValue()

I don't think this should be something the user has to do. This is probably a bug.

This issue was fixed in the build that was uploaded today (3/15). Please let us know if you continue to see this behavior after upgrading.