{"record":{"id":"8ab32814d89c75f2","repo":"instructure/canvas-lms","slug":"invalid-submission-type-for-new-assignment-submission-type","errorCode":null,"errorMessage":"Invalid submission_type for new assignment: #{submission_type[:type]}","messagePattern":"Invalid submission_type for new assignment: #(.+?)","errorType":"http","errorClass":"ActionController::BadRequest","httpStatus":400,"severity":"error","filePath":"app/models/lti/line_item.rb","lineNumber":92,"sourceCode":"        context:,\n        name: params[:label],\n        points_possible: params[:score_maximum],\n        submission_types: \"none\",\n        due_at: params[:end_date_time],\n        unlock_at: params[:start_date_time]\n      }\n\n      submission_type = params[AGS_EXT_SUBMISSION_TYPE]\n      unless submission_type.nil?\n        if Assignment::OFFLINE_SUBMISSION_TYPES.include?(submission_type[:type].to_sym)\n          assignment_attr[:submission_types] = submission_type[:type]\n          assignment_attr[:external_tool_tag_attributes] = {\n            url: submission_type[:external_tool_url]\n          }\n\n          params = extract_extensions(params)\n        else\n          raise ActionController::BadRequest, \"Invalid submission_type for new assignment: #{submission_type[:type]}\"\n        end\n      end\n\n      line_item = nil\n      if assignment.blank?\n        # Creating a new assignment of submission type external_tool creates a \"default\"\n        # LineItem (and associated ResourceLink) which we can just modify & use\n        assignment = Assignment.create!(assignment_attr)\n        line_item = assignment.line_items.first\n      end\n\n      line_item ||= new(assignment:, root_account_id: assignment.root_account_id)\n      attrs = params.to_h.merge(coupled: false).compact\n      attrs[:client_id] = tool.global_developer_key_id if tool\n      line_item.update!(attrs)\n      line_item\n    end\n  end","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/lti/line_item.rb#L74-L110","documentation":"Lti::LineItem creation supports only certain submission types when building the backing assignment. If a new assignment is requested with a submission_type whose :type is not one of the supported values (e.g. not 'external_tool' or 'online_upload' paths handled above), an ActionController::BadRequest is raised.","triggerScenarios":"POSTing an AGS line item (LTI 1.3 Assignment and Grade Services) whose tag attributes include a submission_type with an unsupported :type for a new assignment.","commonSituations":"Malformed LTI AGS requests from external tools; clients sending submission types like 'online_text_entry' or arbitrary strings where only external_tool/online_upload are accepted for new assignments; API clients building requests by hand.","solutions":["Send a supported submission_type :type (e.g. external_tool with external_tool_url) or omit submission_type for new assignments","Attach the line item to an existing assignment instead of creating a new one when using unsupported submission types","Rescue ActionController::BadRequest in the AGS controller and return a 400 with a clear message to the tool"],"exampleFix":"// before\n{ \"scoreMaximum\": 10, \"tag\": \"foo\", \"submission_type\": { \"type\": \"online_text_entry\" } }\n// after\n{ \"scoreMaximum\": 10, \"tag\": \"foo\", \"submission_type\": { \"type\": \"external_tool\", \"external_tool_url\": \"https://tool.example/launch\" } }","handlingStrategy":"validation","validationCode":"allowed = [\"external_tool\", \"online_upload\"]\nraise ActionController::BadRequest unless allowed.include?(submission_type[:type])","typeGuard":null,"tryCatchPattern":"begin\n  Lti::LineItem.build_assignment(...)\nrescue ActionController::BadRequest => e\n  render json: { errors: e.message }, status: :bad_request\nend","preventionTips":["Only send supported submission_type values for new assignments","Attach to existing assignments for other submission types","Document accepted submission types for AGS clients"],"tags":["lti","ags","request-validation"],"backgroundTag":"invalid-enum-value","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"}