Charcoal-SE / SmokeDetector

Headless chatbot that detects spam and posts links to it in chatrooms for quick deletion.
https://metasmoke.erwaysoftware.com
Apache License 2.0
474 stars 182 forks source link

No chat messages for reports via FDSC #939

Closed Glorfindel83 closed 7 years ago

Glorfindel83 commented 7 years ago

As mentioned here, reports via FDSC are correctly received by metasmoke. However, Smokey doesn't post them in chat and doesn't create a 'real' report in metasmoke. I assume those two are related. Probably, the websocket is broken.

angussidney commented 7 years ago

I've tested this, and Smokey appears to be throwing this error upon recieving the data from MS:

[10:45:19] 'NoneType' object has no attribute 'post_id'
Traceback (most recent call last):
  File "/home/ubuntu/charcoal/SmokeDetector/metasmoke.py", line 47, in init_websocket
    Metasmoke.handle_websocket_data(data)
  File "/home/ubuntu/charcoal/SmokeDetector/metasmoke.py", line 126, in handle_websocket_data
    why=why)
  File "/home/ubuntu/charcoal/SmokeDetector/spamhandling.py", line 101, in handle_spam
    datahandling.add_post_site_id_link((post.post_id, post.post_site, "answer"), post.parent.post_id)
AttributeError: 'NoneType' object has no attribute 'post_id'

The MS websocket also seems to drop off after this error.

@teward I think you were the one who worked on the post object refactor, could you have a look at this if you get the chance? Thanks.

j-f1 commented 7 years ago

The issue here seems to be that the post doesn’t get its parent set, even though it’s an answer.

teward commented 7 years ago

Is this still an issue, because I don't see this happening right now on Lunar Eclipse. And it's been up for a better part of a day now (after @angussidney's decided to stuff itself with the SSH key issue).

Can we get some examples of such posts which this was observed on?

//cc @angussidney @j-f1 @Glorfindel83

angussidney commented 7 years ago

To test @j-f1's theory, I tried to report a question, and it worked perfectly.

@teward this is an issue that is only occurs when an answer is reported via the MS API, not during normal operation. To reproduce, simply try reporting any answer via the API. I've tested it on your instance, and the issue is still occuring.

teward commented 7 years ago

If this is only happening when the MS API is the only report source then perhaps we should start by looking at what is sent by MS to Smokey to process this (@Undo). Because I’m not sure we have a mechanism to specifically handle MS API reports differently from standard posts.

Sent from my iPhone. Please excuse any typos, as they are likely to happen by accident.

On Sep 23, 2017, at 22:35, angussidney notifications@github.com wrote:

To test @j-f1's theory, I tried to report a question, and it worked perfectly.

@teward this is an issue that is only occurs when an answer is reported via the MS API, not during normal operation. To reproduce, simply try reporting any answer via the API. I've tested it on your instance, and the issue is still occuring.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

angussidney commented 7 years ago

[status-fixed] by 70b9796

This was caused by a simple misspelling on this line, where CamelCase was used instead of snake_case (as should be the case). The Post() constructor was therefore considering all answers to be questions, due to the missing is_answer attribute, causing the parent attribute to also be absent, causing issues further down the line.