Implicit data type conversion in Javascript vs explicit data type conversion in Python
A Google App Engine story:
Having setup your REST API in NodeJS using Express and middle-wares shipping it to Google App Engine, you expect that, when you put a boolean value false or true is actually a boolean.
You will be surprised that some of your functionalities are enabled, though you think, you did everything right. You YAML file fits every standard of YAML boolean types:
Regexp:
y|Y|yes|Yes|YES|n|N|no|No|NO
|true|True|TRUE|false|False|FALSE
|on|On|ON|off|Off|OFF
But you find something in the app engine configuration in the Google App Engine UI which makes you thinking you could have done something wrong.
Noooo, Google’s developers can never be wrong. It must be you. :D
So you keep searching, checking your code base and your build and deployment jobs twice or three times. And then finally, when you debug and cat and verbose everything out, you see, that during the deployment, Google is converting the YAML to a JSON.
But why would it use strings instead of boolean data types?
Digging deeper, you will eventually figure out, that Google has to handle boolean data types specially for Python and return a string.
Special handling for boolean values, since the Python version (True/False) is incompatible with the JSON version (true/false).
Args: value: value to convert.
Returns: Value as a string.
The problem here is now, that the original author of the app.yaml thought about the implicit data type conversion in Javascript using explicitly a boolean data type, expecting still having a boolean data type after the deployment of the app on Google App Engine.
The Google author did not.
But Google has a nice tip. :)
Tip: Consider programmatically generating the
app.json
configuration file.
🤪👏 Yep, this would be the solution.
Let me give you some examples of implicit data type conversion in Javascript. So that you have an idea of what to think about when building tools for everybody.
The difference between checking if a value equals boolean true and if a string exists.