haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.04k stars 662 forks source link

[core] TypeError: Cannot read properties of undefined (reading 'name') #3361

Closed analogic closed 4 months ago

analogic commented 4 months ago
[CRIT] [-] [core] TypeError: Cannot read properties of undefined (reading 'name')
[CRIT] [-] [core]     at ResultStore._log (/usr/lib/node_modules/Haraka/node_modules/haraka-results/index.js:226:25)
[CRIT] [-] [core]     at ResultStore.add (/usr/lib/node_modules/Haraka/node_modules/haraka-results/index.js:101:17)
[CRIT] [-] [core]     at mxErr (/usr/lib/node_modules/Haraka/plugins/mail_from.is_resolvable.js:73:17)
[NOTICE] [-] [core] Shutting down

I came across this bug in a random test. https://github.com/haraka/Haraka/blob/f4cc2a61dc3b55b919451a010d5b2fee063e9728/plugins/mail_from.is_resolvable.js#L73 It seems that this is used in the wrong context when catching an exception.

msimerson commented 4 months ago

Indeed. Two ways to solve that:

1

-        results.add(this, {err: `${domain}:${err.message}`});
+        results.add(plugin, {err: `${domain}:${err.message}`});

2

-    function mxErr (err) {
+    const mxErr = (err) => {