instructure/canvas-lms · error · ArgumentError
Missing required asset parameter #
Error message
Missing required asset parameter #{asset_param_name} What it means
Guard in Lti::Pns::LtiAssetProcessorContributionNoticeBuilder#validate_params!: an entry in params[:assets] is missing one of the REQUIRED_ASSETS_PARAMS keys, so ArgumentError is raised while constructing a Caliper/asset-processor notification. It's a constructor-time input validation for the notice payload.
Solutions
- Ensure every entry in params[:assets] contains all REQUIRED_ASSETS_PARAMS keys with truthy values
- Normalize asset hashes (symbolize keys, default-fill known values) before constructing the builder
- Filter out assets missing required fields upstream, or validate the array before calling initialize
Example fix
// before
params[:assets] = [{ id: 1 }] # missing other required asset params
// after
req = Lti::Pns::LtiAssetProcessorContributionNoticeBuilder::REQUIRED_ASSETS_PARAMS
params[:assets] = raw_assets.select { |a| req.all? { |k| a[k] } } Defensive patterns
Strategy: validation
Validate before calling
req = Lti::Pns::LtiAssetProcessorContributionNoticeBuilder::REQUIRED_ASSETS_PARAMS
bad = params[:assets].to_a.reject { |a| req.all? { |k| a[k] } }
raise "invalid assets" unless bad.empty? Type guard
def valid_asset?(a) = Lti::Pns::LtiAssetProcessorContributionNoticeBuilder::REQUIRED_ASSETS_PARAMS.all? { |k| a[k] } Try / catch
begin
Builder.new(params)
rescue ArgumentError => e
Rails.logger.error("PNS builder: #{e.message}")
end Prevention
- Sanitize each asset hash against REQUIRED_ASSETS_PARAMS
- Symbolize keys before validation
- Drop or repair incomplete assets upstream
When it happens
Trigger: Passing params[:assets] where at least one asset hash is missing one of the REQUIRED_ASSETS_PARAMS keys (or holds nil/false).
Common situations: Building asset arrays from partial records (some assets lack the field); symbol vs string key mismatches in the asset hashes; schema drift between producer and builder.
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 parameter: asset_report_service_url when…
- Missing required parameter: #
- Invalid contribution_status: #
- Access token expired
- Access token invalid - signature likely incorrect
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/ebff7afa3f75d045.
Report an issue: GitHub.
Appendix: source
Thrown at app/models/lti/pns/lti_asset_processor_contribution_notice_builder.rb:58
SUBMITTED,
DELETED,
HIDDEN
].freeze
def initialize(params)
validate_params!(params)
@params = params
ensure_lti_ids
super()
end
def validate_params!(params)
REQUIRED_PARAMS.each do |param_name|
raise ArgumentError, "Missing required parameter: #{param_name}" unless params[param_name]
end
params[:assets].each do |asset|
REQUIRED_ASSETS_PARAMS.each do |asset_param_name|
raise ArgumentError, "Missing required asset parameter #{asset_param_name}" unless asset[asset_param_name]
end
end
if params[:assets].any? && params[:asset_report_service_url].blank?
raise ArgumentError, "Missing required parameter: asset_report_service_url when assets are present"
end
unless VALID_CONTRIBUTION_STATUSES.include?(params[:contribution_status])
raise ArgumentError, "Invalid contribution_status: #{params[:contribution_status]}. Must be one of: #{VALID_CONTRIBUTION_STATUSES.join(", ")}"
end
end
def notice_type
NoticeTypes::ASSET_PROCESSOR_CONTRIBUTION
end
def custom_ims_claims(_tool)
discussion_entry_version = @params[:discussion_entry_version]
discussion_entry = discussion_entry_version.discussion_entry
{View on GitHub (pinned to 1c9f0bb801)