patch: Adding for null checks in generateUserAgent() to avoid undefined runtime errors#1952
patch: Adding for null checks in generateUserAgent() to avoid undefined runtime errors#1952iAmmarTahir wants to merge 2 commits intoapache:masterfrom iAmmarTahir:fix/gremlin-js-null-checks
Conversation
…ed runtime errors
Codecov Report
@@ Coverage Diff @@
## master #1952 +/- ##
============================================
+ Coverage 68.54% 68.61% +0.06%
- Complexity 9088 9098 +10
============================================
Files 854 854
Lines 41185 41185
Branches 5598 5598
============================================
+ Hits 28231 28259 +28
+ Misses 10980 10951 -29
- Partials 1974 1975 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
@iAmmarTahir Thanks for catching this error and submitting this fix. I would like to add that this would be further improved if a default value of 'NotAvailable' was provided as in Also I would like to ask if you could target this PR to 3.5-dev or 3.6-dev. Our master branch contains the code which will eventually make up the next major release (3.7.0). To have your changes brought into upcoming minor releases (3.5.6, 3.6.3) the changes will need to be in the corresponding dev branches. You should always target the earliest branch you wish to support as changes will be merged forward (eg. if your PR is merged into 3.5-dev, we will also merge it forward into 3.6-dev and master). One wrinkle is that the 3.5.x branch is using node v10 which does not support the |
|
I also want to note that this PR failed the JS CI tests as the linter is currently configured for ecma 2017 which is roughly equivalent to node v10. I have submitted a PR to bump this to version 2021 which is fully supported by node v16 and will prevent the linter from rejecting the use of |
|
@Cole-Greer I have addressed the issues that you mentioned and removed optional chaining to support compatibility for NodeJS v10. I will target this branch towards |
While using Gremlin-javascript in production, I faced an undefined error in
lib/utils.js. Further investigation revealed that the fields were not correctly checked for nulls. This PR aims to add proper null checks to avoid undefined errors on runtime.The error screenshot:

Gremlin version: v3.6.2
Node version: v14.17.4
NPM version: 7.19.1