{"record":{"id":"15c6d9d7869b45eb","repo":"instructure/canvas-lms","slug":"invalid-submission-type","errorCode":null,"errorMessage":"Invalid submission type","messagePattern":"Invalid submission type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/models/abstract_assignment.rb","lineNumber":2753,"sourceCode":"  ALLOWABLE_SUBMIT_HOMEWORK_OPTS = (SUBMIT_HOMEWORK_ATTRS +\n                                    %w[comment group_comment attachments require_submission_type_is_valid resource_link_lookup_uuid student_id]).to_set\n\n  def submit_homework(original_student, opts = {})\n    raise \"Student Required\" unless original_student\n\n    eula_timestamp = opts[:eula_agreement_timestamp]\n    webhook_info = assignment_configuration_tool_lookups.take&.webhook_info\n    should_add_proxy = false\n\n    if opts[:proxied_student]\n      current_user = original_student\n      original_student = opts[:proxied_student]\n      should_add_proxy = true\n    end\n\n    if opts[:submission_type] == \"student_annotation\"\n      raise \"Invalid Attachment\" if opts[:annotatable_attachment_id].blank?\n      raise \"Invalid submission type\" unless annotated_document?\n      # Prevent the case where a user clicks Submit on a stale tab, expecting\n      # to submit one set of work, only for another set to be submitted\n      # instead.\n      raise \"Invalid Attachment\" if opts[:annotatable_attachment_id].to_i != annotatable_attachment_id\n    end\n\n    # Only allow a few fields to be submitted.  Cannot submit the grade of a\n    # homework assignment, for instance.\n    opts.each_key do |k|\n      opts.delete(k) unless ALLOWABLE_SUBMIT_HOMEWORK_OPTS.include?(k.to_s)\n    end\n\n    comment = opts.delete(:comment)\n    group_comment = opts.delete(:group_comment)\n    group, students = group_students(original_student)\n    homeworks = []\n    primary_homework = nil\n","sourceCodeStart":2735,"sourceCodeEnd":2771,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/abstract_assignment.rb#L2735-L2771","documentation":"For student_annotation submissions, Canvas requires the assignment's annotatable attachment to be an annotated-document type (annotated_document? check); submitting with student_annotation when the attached file is not an annotation-capable document raises 'Invalid submission type'.","triggerScenarios":"Submitting with submission_type 'student_annotation' while the assignment's annotatable attachment is not a supported annotated document (e.g. wrong file type attached, annotation feature set but attachment is an unsupported format, or assignment not configured as student annotation task).","commonSituations":"Teacher attaches an unsupported file type as the annotated document; assignment submission_types changed after creation leaving inconsistent config; API clients forcing student_annotation on a normal assignment.","solutions":["Confirm the assignment's annotatable attachment is a supported annotated document type (PDF etc.) and re-attach if not","Verify the assignment's submission_types actually includes 'student_annotation'","Send the correct submission_type for the assignment (e.g. 'online_upload') if annotation was not intended"],"exampleFix":"# before\nsubmit({ submission_type: 'student_annotation', annotatable_attachment_id: 42 })\n# after\nif assignment.annotated_document?\n  submit({ submission_type: 'student_annotation', annotatable_attachment_id: assignment.annotatable_attachment_id })\nend","handlingStrategy":"validation","validationCode":"const isStudentAnnotation = assignment.submissionTypes?.includes('student_annotation');\nif (isStudentAnnotation && !assignment.annotatedDocument) {\n  throw new Error('Assignment is not configured with an annotated document');\n}","typeGuard":"function acceptsStudentAnnotation(assignment) {\n  return assignment != null &&\n    Array.isArray(assignment.submissionTypes) &&\n    assignment.submissionTypes.includes('student_annotation') &&\n    assignment.annotatedDocument != null;\n}","tryCatchPattern":"try {\n  await submit({ submissionType: 'student_annotation' });\n} catch (e) {\n  if (e.message === 'Invalid submission type') {\n    showError('This assignment does not accept student annotation submissions.');\n  }\n}","preventionTips":["Validate file type when a teacher attaches the annotated document","Keep submission_types and the annotatable attachment config consistent when editing assignments","Send the submission_type that matches the assignment's configured types","Add server-side pre-checks in the submission API mirroring annotated_document?"],"tags":["submissions","student-annotation","validation"],"backgroundTag":"invalid-argument-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"}