instructure/canvas-lms · error · EmbedNotFoundError
Resource not found in scan for key: #
Error message
Resource not found in scan for key: #{resource_group_key} What it means
After locating the scan, validate_embed_exists_in_scan! checks scan.results[:resources] for the embed's resource_group_key. If the scan results have no entry for that key, EmbedNotFoundError is raised, meaning the embed's resource was never captured (or results were trimmed) during the scan phase.
Solutions
- Re-run the youtube embed scan so results include the new/changed resource
- Confirm the embed hash's resource_type and id match what the scan recorded (key format 'Type|id')
- Inspect scan.results[:resources].keys to see which keys the scan actually captured
- Ensure conversion is not racing an in-progress re-scan that reset results
Example fix
// before
service.convert_embed(scan_id, { resource_type: 'Assignment', id: bad_id, src: url })
// after
scan = YoutubeMigrationService.find_scan(course, scan_id)
key = "Assignment|#{assignment.id}"
if scan.results[:resources].blank? || scan.results[:resources][key.to_sym].blank?
YoutubeMigrationService.run_scan(course) # refresh results
end
service.convert_embed(scan_id, embed) Defensive patterns
Strategy: validation
Validate before calling
key = "#{embed[:resource_type]}|#{embed[:id]}"
scan = YoutubeMigrationService.find_scan(course, scan_id)
raise 'resource missing from scan; re-scan required' if scan.results.blank? || scan.results.dig(:resources, key.to_sym).blank? Try / catch
begin service.convert_embed(scan_id, embed) rescue YoutubeMigrationService::EmbedNotFoundError YoutubeMigrationService.run_scan(course) service.convert_embed(scan_id, embed) end
Prevention
- Re-scan after any content edit before converting
- Convert promptly after scanning; don't let results go stale
- Verify resource_type/id values exactly match what the scan recorded
When it happens
Trigger: convert_embed called with an embed whose resource_group_key (type|id) is absent from the scan's results hash, including when the resources hash itself is blank but total results exist for other keys.
Common situations: Embed added to the content after the scan ran; scan results truncated or partially saved; wrong resource_type/id embedded so the computed key doesn't match; results reset by a re-scan in progress.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Scan not found for id: #
- Cannot validate existence for resource type: #
- Checkpoint '# ' not found
- Checkpoints not found
- Course not found
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/a91f61bfcfd73b36.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/youtube_migration_service.rb:153
def initialize(course)
self.course = course
end
def validate_scan_exists!(scan_id)
YoutubeMigrationService.find_scan(course, scan_id)
rescue ActiveRecord::RecordNotFound
raise EmbedNotFoundError, "Scan not found for id: #{scan_id}"
end
def validate_embed_exists_in_scan!(scan_id, embed)
scan = YoutubeMigrationService.find_scan(course, scan_id)
resource_group_key = resource_group_key_for(embed)
return if scan.results.blank? || scan.results[:resources].blank?
resource = scan.results[:resources][resource_group_key]
raise EmbedNotFoundError, "Resource not found in scan for key: #{resource_group_key}" if resource.blank?
embed_exists = resource[:embeds].any? do |scan_embed|
scan_embed[:src] == embed[:src] &&
scan_embed[:field].to_s == embed[:field].to_s &&
scan_embed[:resource_type] == embed[:resource_type]
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_typeView on GitHub (pinned to 1c9f0bb801)