Skip to content

Force check and typecast params to string before truncating

Choose a tag to compare

@bs-amitmahajan29 bs-amitmahajan29 released this 09 Jan 09:25
· 3 commits to master since this release
d16a08a

In v1.7.3 we had faced an issue wherein there were 2 scenarios when the package was breaking.

  • When the data.request.params were null/empty as they were absent itself
  • When the data.request.params were passed as dictionary from the package itself

In both the cases, the .substring() was breaking with below traceback

Running in production mode                                                                                                                                                                                                                                                 │
│ {"data":{},"log":{"dynamic_data":"listening to port 3000","kind":"listening to port 3000","level":"info"},"meta":{"format":{"category":"server","version":5},"timestamp":"2024-01-08T16:28:17.933Z"}}                                                                      │
│ /app/src/node_modules/chitragupta/lib/chitragupta/util.js:37                                                                                                                                                                                                               │
│   data.data.request.params = data.data.request.params.substring(0, fieldLimits.PARAMS) || true;                                                                                                                                                                            │
│                                                       ^                                                                                                                                                                                                                    │
│                                                                                                                                                                                                                                                                            │
│ TypeError: Cannot read properties of undefined (reading 'substring')                                                                                                                                                                                                       

Hence as part of this release we have force typecasted the data.request.params to string when it's an dictionary type and kept it's fallback value as empty string.
PR: #26