Ruby Error

ActionController::UnknownFormat

ActionController::UnknownFormat is raised when a request asks for a format (like JSON or XML) that the controller action doesn't support via respond_to.

Common causes

  • Request with Accept header for unsupported format
  • URL with unsupported extension (.json, .xml)
  • Missing respond_to block in controller
  • API endpoint missing JSON response
  • Bots requesting unusual formats

How to fix it

  • Add respond_to block with supported formats
  • Use respond_to with any format fallback
  • Rescue and return appropriate error
  • Add default format to route
  • Implement proper content negotiation

Example

ActionController::UnknownFormat example
# Error when requesting /users.xml without XML support
# => ActionController::UnknownFormat

# Fix with respond_to
def show
  @user = User.find(params[:id])
  respond_to do |format|
    format.html
    format.json { render json: @user }
    format.any { head :not_acceptable }
  end
end

# Or rescue globally
rescue_from ActionController::UnknownFormat do
  head :not_acceptable
end

Track ActionController::UnknownFormat with Checkend

Checkend automatically captures ActionController::UnknownFormat errors in your Ruby application with full context:

  • Complete backtrace with syntax highlighting
  • Request context (URL, params, headers)
  • Automatic grouping of similar errors
  • Instant notifications when errors occur

Stop debugging in production

Get full error context and fix issues faster with self-hosted error tracking.