instructure/canvas-lms · error · ArgumentError
Must provide at least course_id
Error message
Must provide at least course_id
What it means
enqueue_rollup_calculation in CanvasOutcomesHelper enqueues outcome rollup calculation jobs and requires a course_id to scope the work. It raises ArgumentError immediately when course_id is nil, before checking the outcomes_rollup_propagation feature flag.
Solutions
- Always pass course_id: when calling enqueue_rollup_calculation
- Guard the call site: skip enqueueing when course_id is nil instead of relying on the raise
- Trace back why the course was missing (missing param, bad association) and fix at the source
- Ensure the caller has the course loaded from params[:course_id] before invoking
Example fix
// before enqueue_rollup_calculation(student_id: student.id, outcome_id: outcome.id) // after enqueue_rollup_calculation(course_id: course.id, student_id: student.id, outcome_id: outcome.id)
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'Must provide at least course_id' unless course_id enqueue_rollup_calculation(course_id: course_id, ...)
Try / catch
begin
enqueue_rollup_calculation(course_id: course.id)
rescue ArgumentError => e
Rails.logger.warn("skipped rollup enqueue: #{e.message}")
end Prevention
- Require course context in the controller before the helper call
- Guard call sites: return early when course is nil
- Keyword-arg name changes: search all callers when renaming
When it happens
Trigger: Calling enqueue_rollup_calculation without course_id (or with course_id: nil), e.g. from a controller where the course param was absent, or from a job/callback that conditionally sets the course.
Common situations: A request missing the course context; refactoring changed the keyword argument name so the old value no longer binds; a batch job iterating items where some lack an associated course.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- setting_name cannot be nil
- setting_name must be a symbol or string
- Unsupported type_cast `#
- A new_id, '# ', referenced an existing # and the # with #…
- A new_integration_id, '#
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/5d9f22c160b00721.
Report an issue: GitHub.
Appendix: source
Thrown at app/helpers/canvas_outcomes_helper.rb:241
# test_cluster? and test_cluster_name are true and not nil for nonprod environments,
# like beta or test
if ApplicationController.test_cluster?
:"#{ApplicationController.test_cluster_name}_domain"
else
:domain
end
end
def build_request_url(protocol, domain, endpoint, params)
url = "#{protocol}://#{domain}/#{endpoint}"
if params.present?
url += "?" + params.to_query
end
url
end
def enqueue_rollup_calculation(course_id: nil, student_id: nil, outcome_id: nil)
raise ArgumentError, "Must provide at least course_id" unless course_id
return unless Account.site_admin.feature_enabled?(:outcomes_rollup_propagation)
if course_id && student_id
Outcomes::StudentOutcomeRollupCalculationService.calculate_for_student(
course_id:,
student_id:
)
else
Outcomes::StudentOutcomeRollupCalculationService.calculate_for_course(
course_id:
)
end
end
private
def artifact_type_lookup(artifact)
case artifact.class.to_sView on GitHub (pinned to 1c9f0bb801)