instructure/canvas-lms · error
Invalid submission type
Error message
Invalid submission type
What it means
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'.
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
Example fix
# before
submit({ submission_type: 'student_annotation', annotatable_attachment_id: 42 })
# after
if assignment.annotated_document?
submit({ submission_type: 'student_annotation', annotatable_attachment_id: assignment.annotatable_attachment_id })
end Defensive patterns
Strategy: validation
Validate before calling
const isStudentAnnotation = assignment.submissionTypes?.includes('student_annotation');
if (isStudentAnnotation && !assignment.annotatedDocument) {
throw new Error('Assignment is not configured with an annotated document');
} Type guard
function acceptsStudentAnnotation(assignment) {
return assignment != null &&
Array.isArray(assignment.submissionTypes) &&
assignment.submissionTypes.includes('student_annotation') &&
assignment.annotatedDocument != null;
} Try / catch
try {
await submit({ submissionType: 'student_annotation' });
} catch (e) {
if (e.message === 'Invalid submission type') {
showError('This assignment does not accept student annotation submissions.');
}
} Prevention
- 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?
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid Attachment
- A course did not pass validation
- A # user did not pass validation (user: # , # : # , error…
- A maximum of 50 assessees can be provided at once
- A maximum of 50 assessors can be provided at once
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/15c6d9d7869b45eb.
Report an issue: GitHub.
Appendix: source
Thrown at app/models/abstract_assignment.rb:2753
ALLOWABLE_SUBMIT_HOMEWORK_OPTS = (SUBMIT_HOMEWORK_ATTRS +
%w[comment group_comment attachments require_submission_type_is_valid resource_link_lookup_uuid student_id]).to_set
def submit_homework(original_student, opts = {})
raise "Student Required" unless original_student
eula_timestamp = opts[:eula_agreement_timestamp]
webhook_info = assignment_configuration_tool_lookups.take&.webhook_info
should_add_proxy = false
if opts[:proxied_student]
current_user = original_student
original_student = opts[:proxied_student]
should_add_proxy = true
end
if opts[:submission_type] == "student_annotation"
raise "Invalid Attachment" if opts[:annotatable_attachment_id].blank?
raise "Invalid submission type" unless annotated_document?
# Prevent the case where a user clicks Submit on a stale tab, expecting
# to submit one set of work, only for another set to be submitted
# instead.
raise "Invalid Attachment" if opts[:annotatable_attachment_id].to_i != annotatable_attachment_id
end
# Only allow a few fields to be submitted. Cannot submit the grade of a
# homework assignment, for instance.
opts.each_key do |k|
opts.delete(k) unless ALLOWABLE_SUBMIT_HOMEWORK_OPTS.include?(k.to_s)
end
comment = opts.delete(:comment)
group_comment = opts.delete(:group_comment)
group, students = group_students(original_student)
homeworks = []
primary_homework = nil
View on GitHub (pinned to 1c9f0bb801)