instructure/canvas-lms · error · ActiveRecord::RecordNotFound

Couldn't find course with API id '#

Error message

Couldn't find course with API id '#{params[:course_id]}'

What it means

Guard in GradeChangeAuditApiController#for_course: api_find(Course, params[:course_id]) returned no course, so the grade-change audit query for that course is refused with ActiveRecord::RecordNotFound.

Solutions

  1. Pass a valid course id (api_find also accepts SIS ids; ensure the id exists)
  2. Confirm the course belongs to the current root account/shard
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/controllers/grade_change_audit_api_controller.rb:165 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/24b26dde1db7a2ec. Report an issue: GitHub.

Appendix: source

Thrown at app/controllers/grade_change_audit_api_controller.rb:165

    events = Auditors::GradeChange.for_assignment(@assignment, query_options)
    render_events(events, polymorphic_url([:api_v1, :audit_grade_change, @assignment]))
  end

  # @API Query by course
  #
  # List grade change events for a given course.
  #
  # @argument start_time [DateTime]
  #   The beginning of the time range from which you want events.
  #
  # @argument end_time [DateTime]
  #   The end of the time range from which you want events.
  #
  # @returns [GradeChangeEvent]
  #
  def for_course
    course = api_find(Course, params[:course_id])
    raise ActiveRecord::RecordNotFound, "Couldn't find course with API id '#{params[:course_id]}'" unless course_authorized?(course)

    events = Auditors::GradeChange.for_course(course, query_options)
    render_events(events, polymorphic_url([:api_v1, :audit_grade_change, course]), course:)
  end

  # @API Query by student
  #
  # List grade change events for a given student.
  #
  # @argument start_time [DateTime]
  #   The beginning of the time range from which you want events.
  #
  # @argument end_time [DateTime]
  #   The end of the time range from which you want events.
  #
  # @returns [GradeChangeEvent]
  #
  def for_student

View on GitHub (pinned to 1c9f0bb801)