instructure/canvas-lms · error · UnsupportedResourceTypeError
Invalid resource group key: #
Error message
Invalid resource group key: #{resource_group_key} What it means
validate_resource_group_key! splits resource_group_key on '|' and requires exactly two non-blank parts. Keys like 'WikiPage', 'WikiPage|', '|123', or with extra pipes raise UnsupportedResourceTypeError because the key cannot identify a resource type + id pair.
Solutions
- Build the key as "#{resource_type}|#{resource_id}" with both values present and nil-checked
- Verify format before calling: key.to_s.split('|').size == 2 and no blank parts
- If an id can contain '|', use a different join scheme and update the validator accordingly
- Log/inspect the offending key — the message echoes exactly what was passed
Example fix
// before
key = "WikiPage|#{page_id}" # page_id is nil => 'WikiPage|'
// after
key = [resource_type, resource_id].then { |t, i| raise 'missing id' if t.blank? || i.blank?; "#{t}|#{i}" } Defensive patterns
Strategy: validation
Validate before calling
def valid_resource_group_key?(key)
parts = key.to_s.split('|')
parts.size == 2 && parts.none?(&:blank?)
end Type guard
def parse_resource_group_key(key)
parts = key.to_s.split('|')
parts.size == 2 && parts.none?(&:blank?) ? parts : nil
end Try / catch
begin
service.convert_embed(scan_id, embed)
rescue YoutubeMigrationService::UnsupportedResourceTypeError => e
raise ArgumentError, "malformed key: #{e.message}"
end Prevention
- Always build keys as "#{type}|#{id}" with nil-checked values
- Never let ids containing '|' reach this API
- Unit-test key construction with nil/empty ids
When it happens
Trigger: convert_embed with a malformed resource group key: missing id, empty type segment, an id containing a literal '|', or a key built by string concatenation with nil.
Common situations: Building the key manually as "#{type}|#{id}" where id is nil; splitting/rejoining keys incorrectly; keys copied from logs with truncation; ids that themselves contain '|' (rare, but breaks the 2-part rule).
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Cannot validate existence for resource type: #
- Unsupported resource type: #
- An institutional tag category did not pass validation
- app '# ' must be one of: #
- cannot change column: captions - locked by Master Course
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/13c8a0f004b0cf8a.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/youtube_migration_service.rb:183
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)
when "DiscussionTopic", "Announcement"
course.discussion_topics.find(resource_id)
when "DiscussionEntry"
DiscussionEntry.find(resource_id)
when "CalendarEvent"
course.calendar_events.find(resource_id)View on GitHub (pinned to 1c9f0bb801)