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
477 stars 182 forks source link

An answer can be undeleted while the question it belongs to is still deleted #7489

Open tripleee opened 1 year ago

tripleee commented 1 year ago

What problem has occurred? What issues has it caused?

Transcript here. At the very least, it should be more obvious what's going wrong. Probably add a try/except and an error message for this corner case, even though it's arguably esoteric.

What would you like to happen/not happen?

Smokey should be prepared for the parent link from the API to be missing, or whatever exactly it is that is failing here.

Analyzing the behavior probably requires mod privileges in practice, or at the very least helpful coordination with a mod who is prepared to recreate the conditions to repro.

makyen commented 1 year ago

This is something that's happened a few times previously (the error is recognizable and consistent). Our current scanning process requires that if an answer is reported to SD, then the question also needs to be available via the SE API. In other words, to report a deleted answer, the question needs to also be undeleted. I'm unsure if it's worthwhile to rework things in order to remove that requirement. I haven't looked for what all the existing dependencies are, but removing the need for the question would, potentially, limit future detections.

On the other hand, it would be reasonable for SD to recognize that the question being currently deleted is likely the problem and for SD to suggest that the person reporting the answer should check to verify that the question is also undeleted. SD doesn't have a way to know that's the actual issue, because the SE API doesn't provide data about deleted posts, not even an explicit indicator that the post is deleted.

The typical indication from the SE API that a post is deleted is merely that no data is returned when requesting data for the post, so we would generally be making a guess (but a good guess) that the issue was that the question was deleted while the answer was undeleted.

Side note: it is, in fact, possible to determine that the post is deleted, rather than non-existent, based on there being available flagging options for the post in order to raise an "in need of moderator intervention" flag, but to be able to get the flagging options requires an access_token, which we don't use for SmokeDetector.

codygray commented 1 year ago

[…] to report a deleted answer, the question needs to also be undeleted. I'm unsure if it's worthwhile to rework things in order to remove that requirement.

This is a completely reasonable requirement. Even if it is possible to remove this requirement for this specific edge case, I don't think it is worth the development time to do so.

The main purpose of this bug report is to improve the error message that gets displayed in such cases, with the hope of cluing the reporting moderator in to the actual problem.

[…] the error is recognizable and consistent […]

Only if you have already seen and investigated it before. Otherwise, it's completely opaque and non-recognizable.

If you report a post that's been deleted, as I did here, you get back the error message:

Post 1: Could not find data for this post in the API. It may already have been deleted.

That's the same error that I would expect to get when I report an answer associated with a deleted question.

Instead, I get:

I hit an error while trying to run that command; run !!/errorlogs for details.

and when running !!/errorlogs, I see:

### AttributeError on teward/Thoth at 2023-01-20T06:00:25Z: 'bool' object has no attribute 'as_dict'
File "/home/smokey/SmokeDetector/chatcommunicate.py", line 528, in __call__
result = self.__func__(*processed_args, alias_used=alias_used)
File "/home/smokey/SmokeDetector/chatcommands.py", line 2098, in report
output = report_posts(urls, msg.owner, msg.room.name, message_url, alias_used, custom_reason)
File "/home/smokey/SmokeDetector/chatcommands.py", line 2323, in report_posts
post._parent = Post(api_response=parent_data.as_dict)

### AttributeError on teward/Thoth at 2023-01-20T05:59:49Z: 'bool' object has no attribute 'as_dict'
File "/home/smokey/SmokeDetector/chatcommunicate.py", line 528, in __call__
result = self.__func__(*processed_args, alias_used=alias_used)
File "/home/smokey/SmokeDetector/chatcommands.py", line 2098, in report
output = report_posts(urls, msg.owner, msg.room.name, message_url, alias_used, custom_reason)
File "/home/smokey/SmokeDetector/chatcommands.py", line 2323, in report_posts
post._parent = Post(api_response=parent_data.as_dict)

It is not clear to me why the former can produce an easily-understood error message, while the latter produces an exceptional condition. This exceptional condition should not occur; it should be caught and displayed to the user as an error message. In other words, it is fine that the operation fails, but the operation should fail gracefully.

Although it might be both possible and desirable, it is not necessary to guess whether the root cause of the problem is the answer undeleted from a deleted question. It is sufficient to report that Smokey couldn't find data for the specified post using the SE API.