instructure/canvas-lms · error · ActionController::InvalidAuthenticityToken

test_error

Error message

test_error

What it means

Intentional test error: InfoController#test_error raises ActionController::InvalidAuthenticityToken with the literal message 'test_error' when params[:status] resolves to 422. This is a diagnostic endpoint for exercising Canvas's error rendering/reporting pipeline, not a real failure.

Solutions

  1. If seen unintentionally, nothing to fix — the endpoint was deliberately called
  2. Avoid calling /info/test_error?status=422 in production traffic
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at app/controllers/info_controller.rb:126 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/111431ccb1733266. Report an issue: GitHub.

Appendix: source

Thrown at app/controllers/info_controller.rb:126

  end

  # for windows live tiles
  def browserconfig
    cancel_cache_buster
    expires_in 10.minutes, public: true
  end

  def test_error
    @context = Course.find(params[:course_id]) if params[:course_id].present?

    if params[:status].present?
      case params[:status].to_i
      when 401
        @unauthorized_reason = :unpublished if params[:reason] == "unpublished"
        @needs_cookies = true if params[:reason] == "needs_cookies"
        return render_unauthorized_action
      when 422
        raise ActionController::InvalidAuthenticityToken, "test_error"
      else
        @not_found_message = "(test_error message details)" if params[:message].present?
        raise RequestError.new("test_error", params[:status].to_i)
      end
    end

    render status: :not_found, template: "shared/errors/404_message"
  end

  def live_events_heartbeat
    Canvas::LiveEvents.heartbeat
    render plain: "heartbeat event sent at #{Time.now.utc.iso8601}"
  end

  def web_app_manifest
    # brand_variable returns a value that we expect to go through a rails
    # asset helper, so we need to do that manually here
    icon = helpers.image_path(brand_variable("ic-brand-apple-touch-icon"))

View on GitHub (pinned to 1c9f0bb801)