{"record":{"id":"e99f86c86f81a3e3","repo":"instructure/canvas-lms","slug":"missing-required-parameter-asset-report-service-url-when","errorCode":null,"errorMessage":"Missing required parameter: asset_report_service_url when assets are present","messagePattern":"Missing required parameter: asset_report_service_url when assets are present","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"app/models/lti/pns/lti_asset_processor_contribution_notice_builder.rb","lineNumber":62,"sourceCode":"\n      def initialize(params)\n        validate_params!(params)\n        @params = params\n        ensure_lti_ids\n        super()\n      end\n\n      def validate_params!(params)\n        REQUIRED_PARAMS.each do |param_name|\n          raise ArgumentError, \"Missing required parameter: #{param_name}\" unless params[param_name]\n        end\n        params[:assets].each do |asset|\n          REQUIRED_ASSETS_PARAMS.each do |asset_param_name|\n            raise ArgumentError, \"Missing required asset parameter #{asset_param_name}\" unless asset[asset_param_name]\n          end\n        end\n        if params[:assets].any? && params[:asset_report_service_url].blank?\n          raise ArgumentError, \"Missing required parameter: asset_report_service_url when assets are present\"\n        end\n        unless VALID_CONTRIBUTION_STATUSES.include?(params[:contribution_status])\n          raise ArgumentError, \"Invalid contribution_status: #{params[:contribution_status]}. Must be one of: #{VALID_CONTRIBUTION_STATUSES.join(\", \")}\"\n        end\n      end\n\n      def notice_type\n        NoticeTypes::ASSET_PROCESSOR_CONTRIBUTION\n      end\n\n      def custom_ims_claims(_tool)\n        discussion_entry_version = @params[:discussion_entry_version]\n        discussion_entry = discussion_entry_version.discussion_entry\n        {\n          for_user: {\n            user_id: @params[:for_user_id],\n          },\n          assetreport: @params[:asset_report_service_url]&.then do |url|","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/lti/pns/lti_asset_processor_contribution_notice_builder.rb#L44-L80","documentation":"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.","triggerScenarios":"Constructing the notice builder with a non-empty assets array but params[:asset_report_service_url] nil or \"\".","commonSituations":"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.","solutions":["Always pass asset_report_service_url when including assets","Skip including assets (or the whole notice) when no asset report service URL is available","Rescue ArgumentError and fall back to a notice without the report link"],"exampleFix":"// before\nbuilder.new(assets: assets, asset_report_service_url: nil)\n// after\nbuilder_params[:asset_report_service_url] ||= default_report_service_url\nbuilder.new(builder_params) if builder_params[:asset_report_service_url].present? || builder_params[:assets].blank?","handlingStrategy":"validation","validationCode":"raise \"missing url\" if params[:assets].present? && params[:asset_report_service_url].blank?","typeGuard":null,"tryCatchPattern":"begin\n  Builder.new(params)\nrescue ArgumentError => e\n  Rails.logger.error(\"PNS builder: #{e.message}\")\nend","preventionTips":["Pass asset_report_service_url whenever assets are present","Gate asset inclusion on URL availability","Add presence validation before construction"],"tags":["lti","params-validation","push-notification"],"backgroundTag":"missing-required-argument","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}