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
TypeError due to missing sanitizeFieldNamesRegExp #3247
Comments
@d0ruk Thanks for the issue! I'll start trying to reproduce this. Are you able to post the full traceback? Perhaps add the |
Here is the stack.
This error was captured on Node.js 14.19.3 with elastic-apm-http-client 11.2.0 & elastic-apm-node 3.43.0. |
That is a code path coming from Central config. Thanks very much, that traceback is helpful! I can reproduce the error and will work on a fix now. I suspect you have APM Agent central config setup in your Kibana to configure
As a workaround, if you need it while I get a fix out, you could remove "sanitize_field_names" from your central configuration in Kibana. |
The crash was with init of config.sanitizeFieldNamesRegExp in the central-config code path. I've fixed that. Other updates: - Updated config normalization of this var -- and similar config vars that set a `${name}RegExp` array var -- initialize the RegExp array to empty before populating it. - Updated the tests to ensure we always add to "central-config-enabled.test.js" whenever a new supported central config var is added. - Updated central-config handling to try/catch and log.error instead of *crashing* if there is an unexpected exception. Partially applied central config isn't great, but it is better than having a DoS avenue where central config can crash agents. For example: {"log.level":"error",...,"remoteConf":{"sanitize_field_names":"password, pass*"},"error":{"type":"TypeError","message":"Cannot read properties of undefined (reading 'push')","stack_trace":"..."},"message":"Central config error: exception while applying changes"} Fixes: #3247
…#3249) The crash was with init of config.sanitizeFieldNamesRegExp in the central-config code path. I've fixed that. Other updates: - Updated config normalization of this var -- and similar config vars that set a `${name}RegExp` array var -- initialize the RegExp array to empty before populating it. - Updated the tests to ensure we always add to "central-config-enabled.test.js" whenever a new supported central config var is added. - Updated central-config handling to try/catch and log.error instead of *crashing* if there is an unexpected exception. Partially applied central config isn't great, but it is better than having a DoS avenue where central config can crash agents. For example: {"log.level":"error",...,"remoteConf":{"sanitize_field_names":"password, pass*"},"error":{"type":"TypeError","message":"Cannot read properties of undefined (reading 'push')","stack_trace":"..."},"message":"Central config error: exception while applying changes"} Fixes: #3247
Hello,
I am initialising the APM client at the top of my main module like so
However, app crashes with a
TypeError: Cannot read property 'push' of undefined
referring to sanitizeFieldNamesRegExp.I do not specify
sanitizeFieldNames
orsanitizeFieldNamesRegExp
in the options, as seen above. The library then uses the default values which are initialized as arrays.Do you have any idea as to why this happens?
The
require('./config')
that come before hasCan this be where the problem is?
I'd appreciate any help/comments on this issue.
Note: I am using elastic-apm-node ^3.42.0 on Node.js 14.
Best,
Doruk
The text was updated successfully, but these errors were encountered: