actionhero
actionhero copied to clipboard
[Bug]: utils function is causing side effects to the input object.
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
utils function is causing side effects to the input object. https://github.com/actionhero/actionhero/blob/9c6b40f98c3f97dcc828d075ed96c707acb7e39f/src/modules/utils/filterObjectForLogging.ts#L13
passing complex/deeply nested object here is a problem since this line creates a shallow copy. therefore, if your deeply nested input is configured to be sanitized, this function will modify the original params
object as well.
this utilitity function should adhere to functional programming philosophy of NO SIDE EFFECTS. original input must not be modified.
Expected Behavior
after calling the function:
const userInput = {
"books": {
"author": "Bob"
}
};
const sanitizedInput = filterObjectForLogging(userInput);
// after this line:
userInput = {
"books": {
"author": "Bob"
}
};
sanitizednput = {
"books": {
"author": "[FILTERED]"
}
};
currently, both will be [FILTERED]
Stack Trace
No response
Environment
Actionhero v26+
Additional context
No response
Thanks @danijeld - Are you able to submit a PR with a fix?