Skip to content

Fix MissingTemplate error for non-HTML home page requests#1337

Closed
maebeale wants to merge 1 commit intomainfrom
maebeale/fix-home-text-format
Closed

Fix MissingTemplate error for non-HTML home page requests#1337
maebeale wants to merge 1 commit intomainfrom
maebeale/fix-home-text-format

Conversation

@maebeale
Copy link
Collaborator

@maebeale maebeale commented Mar 4, 2026

What is the goal of this PR and why is this important?

  • Bots/crawlers requesting the home page with non-HTML formats (e.g. Accept: text/plain) cause a 500 error (ActionView::MissingTemplate) because only index.html.erb exists
  • This wraps the render in respond_to so unsupported formats get a 406 Not Acceptable instead of a 500

How did you approach the change?

  • Added respond_to block in HomeController#index to explicitly handle only format.html
  • Non-HTML format requests now return 406 instead of raising an exception

Anything else to add?

  • Other public-facing controllers have the same vulnerability — a follow-up PR could add a global rescue_from ActionView::MissingTemplate in ApplicationController to handle all cases

🤖 Generated with Claude Code

…page

Bots/crawlers requesting text/plain or other non-HTML formats caused a
500 error because no text template exists. Wrapping in respond_to
returns 406 Not Acceptable for unsupported formats instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale
Copy link
Collaborator Author

maebeale commented Mar 4, 2026

Superseded by #1339 which includes this fix plus robots.txt and rack-attack.

@maebeale maebeale closed this Mar 4, 2026
@maebeale maebeale deleted the maebeale/fix-home-text-format branch March 4, 2026 13:33
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.

1 participant