Skip to content

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500#5736

Merged
sarken merged 2 commits intootwcode:masterfrom
pmonfort:AO3-6531-fix-comment-decorator-500
Apr 15, 2026
Merged

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500#5736
sarken merged 2 commits intootwcode:masterfrom
pmonfort:AO3-6531-fix-comment-decorator-500

Conversation

@pmonfort
Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6531

Purpose

Fixes an ArgumentError: comparison of NilClass with 2 failed crash in the After:create_placeholders_for_orphaned_comments rake
task when orphaned comments have nil values for threaded_left.

Changes:

  • Use filter_map instead of map to skip entries where no orphan comment exists for a given missing_id.
  • Add || 0 fallback in sort_by! so comments with nil threaded_left don't crash the comparison.
  • Replace raise with puts + next when the parent comment cannot be determined, allowing the task to continue processing remaining comments instead of aborting.

Testing Instructions

  1. Run the rake task After:create_placeholders_for_orphaned_comments on a database that contains orphaned comments with nil threaded_left values.
  2. Verify the task completes without raising an error.
  3. Verify that comments with valid threaded_left values still get placeholders created correctly.
  4. Run the new spec: bundle exec rspec spec/lib/tasks/after_tasks.rake_spec.rb -e "when an orphaned comment has nil threaded_left"

References

This fix addresses the error encountered when running the rake task on staging, reported by @brianjaustin.

Credit

Pablo Monfort (he/him)

@pmonfort pmonfort force-pushed the AO3-6531-fix-comment-decorator-500 branch from a84d261 to 64dd9ba Compare April 15, 2026 03:43
@sarken sarken changed the title Ao3 6531 fix comment decorator 500 AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 Apr 15, 2026
@sarken sarken added the Priority: High - Broken on Test Merge immediately after approval label Apr 15, 2026
@sarken sarken merged commit 3787e28 into otwcode:master Apr 15, 2026
29 checks passed
jmalark pushed a commit to jmalark/otwarchive that referenced this pull request Apr 19, 2026
…ode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task
jmalark added a commit to jmalark/otwarchive that referenced this pull request Apr 19, 2026
AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment
jmalark added a commit to jmalark/otwarchive that referenced this pull request Apr 19, 2026
AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment
jmalark added a commit to jmalark/otwarchive that referenced this pull request Apr 19, 2026
AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-7378 Updates for code review

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 add double trailing whitespace to try to get it to let me push whitespace changes after settings changes

AO3-7378 Add trailing new line

AO3-7378 Get my local back to just one line of trailing whitespace

AO3-7378 Still trying to get trailing whitespace settings to cooperate

AO3-7378 Trailing whitespace adjustment

Revert

AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

Try to revert unintended change

Revert

Add trailing whitespace

Try to name and use variable on same line
jmalark added a commit to jmalark/otwarchive that referenced this pull request Apr 20, 2026
AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 Fix the order of en.yml
jmalark added a commit to jmalark/otwarchive that referenced this pull request Apr 22, 2026
AO3-6229 Add static 404 error page (otwcode#5711)

AO3-6531 Fix comment decorator 500 error for orphaned comments (otwcode#5719)

* AO3-6531 Fix comment decorator 500 error when parent comment is physically deleted

* AO3-6531 Add rake task to create placeholders for orphaned comments

* AO3-6531 Rename orphaned_commentable_ids variable to missing_commentable_ids.Suggested by brianjaustin.

AO3-6531 Fix create_placeholders_for_orphaned_comments task 500 (otwcode#5736)

* AO3-6531 - Add spec for orphaned comment with nil threaded_left

* AO3-6531 - Handle nil threaded_left in orphaned comment placeholder task

AO3-7381 Update Devise to 5.0.3 (otwcode#5727)

AO3-6531 Remove after task for placeholder comments (otwcode#5740)

Per comments on the related ticket, this could lead to weird behaviour.
Pulling this out so the fix for the most critical part can go live.

AO3-7080 Fix suspended and banned user check (otwcode#5741)

AO3-7378 Fix the order of en.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants