instructure/canvas-lms · error · ActiveRecord::RecordNotFound
Couldn't find assignment with API id '#
Error message
Couldn't find assignment with API id '#{params[:assignment_id]}' What it means
Guard in GradeChangeAuditApiController#for_assignment: api_find couldn't resolve an active Assignment for params[:assignment_id] (or its context/root account or course authorization check failed), so an audit query is refused with RecordNotFound. Avoids leaking assignment existence across accounts.
Solutions
- Use a valid assignment id visible to the current root account
- Ensure the requesting admin is authorized on the assignment's course (course_authorized?)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/controllers/grade_change_audit_api_controller.rb:144 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/bf5a7fe5888449d1.
Report an issue: GitHub.
Appendix: source
Thrown at app/controllers/grade_change_audit_api_controller.rb:144
include Api::V1::GradeChangeEvent
# @API Query by assignment
#
# List grade change events for a given assignment.
#
# @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_assignment
@assignment = api_find(Assignment.active, params[:assignment_id])
unless @assignment.context.root_account == @domain_root_account && course_authorized?(@assignment.course)
raise ActiveRecord::RecordNotFound, "Couldn't find assignment with API id '#{params[:assignment_id]}'"
end
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]
#View on GitHub (pinned to 1c9f0bb801)