instructure/canvas-lms · error · ArgumentError
Missing required parameter: course
Error message
Missing required parameter: course
What it means
Lti::Pns::LtiContextCopyNoticeBuilder's initialize requires params[:course]; if absent it raises ArgumentError "Missing required parameter: course". A context-copy PNS notice cannot be rendered without knowing which course was copied, so the builder fails fast at construction time.
Solutions
- Pass the loaded Course object (or whatever type :course expects) as params[:course] when constructing the builder.
- Verify the course still exists before scheduling/building the notice; skip the notice if it was deleted.
- Check the caller is passing the Course record, not just a course id, under the :course key.
- Wrap construction in a check: build the notice only if params[:course].present?.
Example fix
// before
Lti::Pns::LtiContextCopyNoticeBuilder.new({ copied_at: time })
// after
Lti::Pns::LtiContextCopyNoticeBuilder.new({ course: course, copied_at: time }) Defensive patterns
Strategy: validation
Validate before calling
return nil unless params[:course].present? Lti::Pns::LtiContextCopyNoticeBuilder.new(params)
Try / catch
begin
Lti::Pns::LtiContextCopyNoticeBuilder.new(params)
rescue ArgumentError => e
Rails.logger.warn("context copy notice skipped: #{e.message}")
end Prevention
- Check course&.persisted? before building the notice
- Skip notification building when the course was deleted mid-job
- Keep a single hash-shape constant shared between job and builder
When it happens
Trigger: Calling Lti::Pns::LtiContextCopyNoticeBuilder.new without a :course key, or with course: nil — e.g. when the copy job runs after the source/destination course lookup returned nil or the course was deleted.
Common situations: Course copy/import jobs enqueued before a hard-delete removed the course; passing the wrong hash (e.g. the job options hash) as params; key renames like course_id vs 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
- Missing required asset parameter #
- Missing required parameter: copied_at
- Missing required parameter: #
- e.message
- Validation failed: Notice type unknown, must be one of
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/02efaffd74785fc2.
Report an issue: GitHub.
Appendix: source
Thrown at app/models/lti/pns/lti_context_copy_notice_builder.rb:26
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module Lti
module Pns
class LtiContextCopyNoticeBuilder < NoticeBuilder
attr_reader :params
def initialize(params = {})
raise ArgumentError, "Missing required parameter: course" unless params[:course]
raise ArgumentError, "Missing required parameter: copied_at" unless params[:copied_at]
@params = params
super()
end
def notice_type
Lti::Pns::NoticeTypes::CONTEXT_COPY
end
def custom_instructure_claims(_tool)
{}
end
def custom_ims_claims(_tool)
course = params[:course]
context = {View on GitHub (pinned to 1c9f0bb801)