instructure/canvas-lms · error · ArgumentError

Missing required parameter: asset_report_service_url when…

Error message

Missing required parameter: asset_report_service_url when assets are present

What it means

Guard in Lti::Pns::LtiAssetProcessorContributionNoticeBuilder#validate_params!: params include assets but asset_report_service_url is blank, so ArgumentError is raised — a notice about assets must carry the report service URL.

Solutions

  1. Always pass asset_report_service_url when including assets
  2. Skip including assets (or the whole notice) when no asset report service URL is available
  3. Rescue ArgumentError and fall back to a notice without the report link

Example fix

// before
builder.new(assets: assets, asset_report_service_url: nil)
// after
builder_params[:asset_report_service_url] ||= default_report_service_url
builder.new(builder_params) if builder_params[:asset_report_service_url].present? || builder_params[:assets].blank?
Defensive patterns

Strategy: validation

Validate before calling

raise "missing url" if params[:assets].present? && params[:asset_report_service_url].blank?

Try / catch

begin
  Builder.new(params)
rescue ArgumentError => e
  Rails.logger.error("PNS builder: #{e.message}")
end

Prevention

When it happens

Trigger: Constructing the notice builder with a non-empty assets array but params[:asset_report_service_url] nil or "".

Common situations: Notices built for submissions without a report service configured; optional URL not plumbed through from the asset processor service; callers passing assets unconditionally without checking URL availability.

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


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/e99f86c86f81a3e3. Report an issue: GitHub.

Appendix: source

Thrown at app/models/lti/pns/lti_asset_processor_contribution_notice_builder.rb:62

      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
        {
          for_user: {
            user_id: @params[:for_user_id],
          },
          assetreport: @params[:asset_report_service_url]&.then do |url|

View on GitHub (pinned to 1c9f0bb801)