instructure/canvas-lms · error · UnsupportedResourceTypeError
Unsupported resource type: #
Error message
Unsupported resource type: #{resource_type} What it means
validate_supported_resource! checks the embed's resource_type against SUPPORTED_RESOURCES (WikiPage, Quizzes::Quiz, QuizQuestion, AssessmentQuestion, DiscussionTopic, Announcement, DiscussionEntry, CalendarEvent, Assignment, CourseSyllabus, Course) plus NEW_QUIZZES_RESOURCES. Anything else raises UnsupportedResourceTypeError.
Solutions
- Use the exact class name string as it appears in SUPPORTED_RESOURCES/NEW_QUIZZES_RESOURCES (e.g. 'Quizzes::Quiz', not 'Quiz')
- Check app/services/youtube_migration_service.rb SUPPORTED_RESOURCES list to confirm the type is migrated; if not, convert that embed manually
- If a new legit type is needed, add it to SUPPORTED_RESOURCES and to validate_resource_exists! handling
- Ensure resource_type is a String (call .to_s and verify against the list)
Example fix
// before embed[:resource_type] = 'Quiz' # typo // after embed[:resource_type] = Quizzes::Quiz.name # 'Quizzes::Quiz', matches SUPPORTED_RESOURCES
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = YoutubeMigrationService::SUPPORTED_RESOURCES + YoutubeMigrationService::NEW_QUIZZES_RESOURCES
raise "unsupported resource_type: #{embed[:resource_type]}" unless SUPPORTED.include?(embed[:resource_type].to_s) Type guard
def supported_resource_type?(t) (YoutubeMigrationService::SUPPORTED_RESOURCES + YoutubeMigrationService::NEW_QUIZZES_RESOURCES).include?(t.to_s) end
Try / catch
begin
service.convert_embed(scan_id, embed)
rescue YoutubeMigrationService::UnsupportedResourceTypeError => e
Rails.logger.info("skipping non-migratable embed: #{e.message}")
end Prevention
- Build resource_type from Klass.name, never a hand-typed string
- Keep SUPPORTED_RESOURCES in sync with any new content types added
- Check the frozen list in app/services/youtube_migration_service.rb before adding embed types
When it happens
Trigger: convert_embed called with embed[:resource_type] not in the supported lists — e.g. a typo, a namespaced class name that doesn't match exactly ('Quizzes::Quiz' vs 'Quiz'), or a genuinely unsupported content type.
Common situations: Custom/plugin content types containing YouTube embeds; class-name drift after refactoring (constant renamed so .name no longer matches the frozen list); passing a symbol instead of the exact string.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Cannot validate existence for resource type: #
- Invalid resource group key: #
- set_type of '# ' not supported. Supported types: #
- An institutional tag category did not pass validation
- app '# ' must be one of: #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/3567dada56906726.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/youtube_migration_service.rb:177
end
raise EmbedNotFoundError, "Embed not found in scan for resource: #{resource_group_key}" unless embed_exists
end
def prepare_new_quiz_resource_type(resource_type)
case resource_type
when /QuizzesNext::Quiz/
"QuizzesNext::Quiz"
when /QuizzesNext::Bank/
"QuizzesNext::Bank"
else
resource_type
end
end
def validate_supported_resource!(resource_type)
supported = SUPPORTED_RESOURCES.include?(resource_type) || NEW_QUIZZES_RESOURCES.include?(resource_type)
raise UnsupportedResourceTypeError, "Unsupported resource type: #{resource_type}" unless supported
end
def validate_resource_group_key!(resource_group_key)
parts = resource_group_key.to_s.split("|")
if parts.size != 2 || parts.any?(&:blank?)
raise UnsupportedResourceTypeError, "Invalid resource group key: #{resource_group_key}"
end
end
def validate_resource_exists!(resource_type, resource_id)
# We don't store New Quizzes Data in Canvas, so we can't validate their existence
return true if NEW_QUIZZES_RESOURCES.include?(resource_type)
case resource_type
when "WikiPage"
course.wiki_pages.find(resource_id)
when "Assignment"
course.assignments.find(resource_id)View on GitHub (pinned to 1c9f0bb801)