Skip to content
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

matchedMessage.path can be an array not a Path object on reload #402

Closed
TheBlueMatt opened this issue Nov 11, 2020 · 1 comment
Closed
Labels
bug Something isn't working next release Implemented but will be released with the next release

Comments

@TheBlueMatt
Copy link

Describe the bug
In report.js, matchedMessage.path is sometimes an array, not a path. I believe this is on restart when it loads up a cached version of the current warning.

Provide an example
See below for st, this is in a path-regex-match filter which fails:

Expected behavior
Hopefully the email sender doesn't crash :)

Are you using the binary or the source code?
Source, on the release branch.

Your information
AS397444.

In getContext in the showPaths > 0 if block, after the content.data.filter filter runs, you can get:
matchedMessage.path: [ 20912, 6939, 57695, 397444 ]
matchedMessage.path.getValues: undefined

(note line number is off by a few here as I added some console.log to get the above info):

TypeError: path.matchedMessage.path.getValues is not a function
    at forEach (/home/bgpalerter/BGPalerter/src/reports/report.js:95:41)
    at Array.forEach (<anonymous>)
    at ReportEmail.getContext (/home/bgpalerter/BGPalerter/src/reports/report.js:92:18)
    at ReportEmail.getEmailText (/home/bgpalerter/BGPalerter/src/reports/reportEmail.js:113:30)
    at ReportEmail.report (/home/bgpalerter/BGPalerter/src/reports/reportEmail.js:141:35)
    at clb (/home/bgpalerter/BGPalerter/src/reports/report.js:50:29)
    at /home/bgpalerter/BGPalerter/src/utils/pubSub.js:15:17
    at new Promise (<anonymous>)
    at _loop (/home/bgpalerter/BGPalerter/src/utils/pubSub.js:14:13)
    at PubSub.publish (/home/bgpalerter/BGPalerter/src/utils/pubSub.js:13:36)
@massimocandela
Copy link
Member

massimocandela commented Nov 21, 2020

Hi @TheBlueMatt,

Nice catch and thanks for reporting.
It was indeed caused by cached path objects that when converted from JSON lose their prototype.
There is no real reason to cache the latest alerts, to avoid duplicates on restart it's enough to store the sent dictionary.
I addressed this, now in release branch. I postponed the release to run it for a week with the new patch.

Please report if you find any issue.

@massimocandela massimocandela added the next release Implemented but will be released with the next release label Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next release Implemented but will be released with the next release
Projects
None yet
Development

No branches or pull requests

2 participants