Skip to content

AO3-7561 Fix 500 when trying to /comments/show_comments on nothing - #5996

Open
danderson wants to merge 3 commits into
otwcode:masterfrom
danderson:push-pmsorkolsknv
Open

AO3-7561 Fix 500 when trying to /comments/show_comments on nothing#5996
danderson wants to merge 3 commits into
otwcode:masterfrom
danderson:push-pmsorkolsknv

Conversation

@danderson

Copy link
Copy Markdown

Pull Request Checklist

Issue

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

Purpose

Fixes a 500 when attempting to view comments without passing any query parameters. With this change, the user is instead redirected back from whence they came, with a flash error noting that you can't view comments on nothing.

Testing Instructions

Navigate to http://archiveofourown.org/comments/show_comments. Without this change, will 500. With this change, will redirect to the homepage with an error flash.

References

https://otwarchive.atlassian.net/browse/AO3-7556 is a similar issue in a different route, with a similar fix. Assuming I didn't screw up this one, I can send a followup PR with that fix too.

Credit

David Anderson (he/him)

Misc notes

This is my first PR to otwarchive. There were no first timer issues open, so I picked a recent Difficulty=Easy bug instead to get my feet wet and figure out the dev workflow.

I chose to handle the nil in the show_comments logic, rather than in the redirect_to_all_comments helper where the 500 triggered. This seems to match the local coding style for handling nil commentables (e.g. new and create), and the helper is also called from places where the commentable is a DB object or similar, and silently swallowing an error in those codepaths didn't seem right.

@danderson
danderson force-pushed the push-pmsorkolsknv branch 2 times, most recently from 07fef2d to be73224 Compare August 23, 2026 04:11
@danderson

Copy link
Copy Markdown
Author

The couple force pushes were to fix rubocop complaints, which all concerned the preexisting code that I moved into the else branch. The fixes are straightforward, but I did have to switch a use of ts() to t() and add a translation string. Those lint fixes aren't very related to the purpose of the PR, so lemme know if you want them split out, and how?

@ASalbenblatt ASalbenblatt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small thing to fix, otherwise it looks good. I also marked your issues as In Review on Jira so no one accidentally picks them up. Someone with more perms should be along soon to help get your account connected so you can update them yourself :)
Also including the ts() to t() conversion in this pr is absolutely expected and a-ok

Comment thread spec/controllers/comments/comments_controller_spec.rb Outdated

@ASalbenblatt ASalbenblatt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks!

@sarken sarken left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, David Anderson!

Thank you so much for this pull request. I've left a quick comment about the error message i18n. Once that's addressed, I think this will be ready to merge.

If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)."

Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you.

Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above.

Comment thread app/controllers/comments_controller.rb Outdated
Signed-off-by: David Anderson <dave@natulte.net>
@danderson

Copy link
Copy Markdown
Author

Thanks for the review! Changes done, assuming CI is happy with what I did.

I emailed otw-coders@ with account info for Jira.

@danderson
danderson requested a review from sarken August 26, 2026 23:07

@sarken sarken left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! (Your Jira permissions should be all set now as well.)

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.

3 participants