Skip to content

fix: handle MySQL backend failures in comment API - #57

Merged
Alam-2U merged 1 commit into
release-ulmofrom
LP-832
Jun 17, 2026
Merged

fix: handle MySQL backend failures in comment API#57
Alam-2U merged 1 commit into
release-ulmofrom
LP-832

Conversation

@Alam-2U

@Alam-2U Alam-2U commented Jun 17, 2026

Copy link
Copy Markdown

Summary

This PR fixes a regression in the MySQL forum backend where comments automatically deleted during spam moderation could trigger a 500 error during comment creation.

Root Cause

When a comment is created, moderate_and_flag_spam() may automatically soft-delete it if spam auto-deletion is enabled. In that case, the moderation result contains "soft_deleted" in actions_taken.

Both create_parent_comment() and create_child_comment() subsequently re-fetch the comment from the backend before preparing the API response. Since the comment has already been soft-deleted, the second fetch returns None, which is then passed to prepare_comment_api_response(), resulting in a 500 error.

The MongoDB implementation already handled this scenario by capturing the moderation result and avoiding the second fetch when the comment had been soft-deleted. The MySQL implementation missed this behavior.

Changes

  • Preserve the original comment snapshot when the post-moderation lookup returns None.
  • Fall back to the previously fetched comment instead of overwriting it with None.
  • Prevent 500 errors for comments that are auto-deleted during spam moderation.

Ticket : LP-831

@Alam-2U Alam-2U closed this Jun 17, 2026
@Alam-2U
Alam-2U deleted the LP-832 branch June 17, 2026 08:45
@Alam-2U
Alam-2U restored the LP-832 branch June 17, 2026 08:46
@Alam-2U Alam-2U reopened this Jun 17, 2026
@Alam-2U
Alam-2U merged commit c0fd6dc into release-ulmo Jun 17, 2026
26 checks passed
@Alam-2U
Alam-2U deleted the LP-832 branch June 17, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants