{"record":{"id":"3567dada56906726","repo":"instructure/canvas-lms","slug":"unsupported-resource-type-resource-type","errorCode":null,"errorMessage":"Unsupported resource type: #{resource_type}","messagePattern":"Unsupported resource type: #(.+?)","errorType":"exception","errorClass":"UnsupportedResourceTypeError","httpStatus":400,"severity":"error","filePath":"app/services/youtube_migration_service.rb","lineNumber":177,"sourceCode":"    end\n\n    raise EmbedNotFoundError, \"Embed not found in scan for resource: #{resource_group_key}\" unless embed_exists\n  end\n\n  def prepare_new_quiz_resource_type(resource_type)\n    case resource_type\n    when /QuizzesNext::Quiz/\n      \"QuizzesNext::Quiz\"\n    when /QuizzesNext::Bank/\n      \"QuizzesNext::Bank\"\n    else\n      resource_type\n    end\n  end\n\n  def validate_supported_resource!(resource_type)\n    supported = SUPPORTED_RESOURCES.include?(resource_type) || NEW_QUIZZES_RESOURCES.include?(resource_type)\n    raise UnsupportedResourceTypeError, \"Unsupported resource type: #{resource_type}\" unless supported\n  end\n\n  def validate_resource_group_key!(resource_group_key)\n    parts = resource_group_key.to_s.split(\"|\")\n    if parts.size != 2 || parts.any?(&:blank?)\n      raise UnsupportedResourceTypeError, \"Invalid resource group key: #{resource_group_key}\"\n    end\n  end\n\n  def validate_resource_exists!(resource_type, resource_id)\n    # We don't store New Quizzes Data in Canvas, so we can't validate their existence\n    return true if NEW_QUIZZES_RESOURCES.include?(resource_type)\n\n    case resource_type\n    when \"WikiPage\"\n      course.wiki_pages.find(resource_id)\n    when \"Assignment\"\n      course.assignments.find(resource_id)","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/youtube_migration_service.rb#L159-L195","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nembed[:resource_type] = 'Quiz' # typo\n// after\nembed[:resource_type] = Quizzes::Quiz.name # 'Quizzes::Quiz', matches SUPPORTED_RESOURCES","handlingStrategy":"validation","validationCode":"SUPPORTED = YoutubeMigrationService::SUPPORTED_RESOURCES + YoutubeMigrationService::NEW_QUIZZES_RESOURCES\nraise \"unsupported resource_type: #{embed[:resource_type]}\" unless SUPPORTED.include?(embed[:resource_type].to_s)","typeGuard":"def supported_resource_type?(t)\n  (YoutubeMigrationService::SUPPORTED_RESOURCES + YoutubeMigrationService::NEW_QUIZZES_RESOURCES).include?(t.to_s)\nend","tryCatchPattern":"begin\n  service.convert_embed(scan_id, embed)\nrescue YoutubeMigrationService::UnsupportedResourceTypeError => e\n  Rails.logger.info(\"skipping non-migratable embed: #{e.message}\")\nend","preventionTips":["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"],"tags":["ruby","validation","unsupported-type","migration"],"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"}