{"record":{"id":"5b7d66d4ebde06bd","repo":"instructure/canvas-lms","slug":"message","errorCode":null,"errorMessage":"$!.message","messagePattern":"\\$!\\.message","errorType":"exception","errorClass":"Canvas::Migration::Error","httpStatus":null,"severity":"error","filePath":"lib/canvas/migration/worker.rb","lineNumber":102,"sourceCode":"    Rails.logger.warn \"Couldn't clear export data for content_migration #{content_migration.id}\"\n  end\n\n  def self.download_attachment(cm, url)\n    att = Attachment.new\n    att.context = cm\n    att.file_state = \"deleted\"\n    att.workflow_state = \"unattached\"\n    att.clone_url(url, false, true, quota_context: cm.context)\n\n    if att.file_state == \"errored\"\n      raise Canvas::Migration::Error, att.upload_error_message\n    end\n\n    cm.attachment = att\n    cm.save!\n    att\n  rescue Attachment::OverQuotaError\n    raise Canvas::Migration::Error, $!.message\n  end\nend\n","sourceCodeStart":84,"sourceCodeEnd":105,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/canvas/migration/worker.rb#L84-L105","documentation":"Canvas::Migration::Worker#download_attachment rescues Attachment::OverQuotaError and re-raises it as Canvas::Migration::Error with the original message. It means the migration could not attach the file because the context (course/user) exceeded its storage quota.","triggerScenarios":"download_attachment (clone_url path) raising Attachment::OverQuotaError when importing course files into a context already at or above its storage quota.","commonSituations":"Importing a large course export into a course with a small quota, user files quota exceeded during course copy, quota lowered after content was created.","solutions":["Increase the course/account storage quota (course advanced settings or account quota settings)","Remove unused files from the target course to free space, then retry the migration","Handle the raised message in the UI to show users the quota problem","For account-level imports, raise default quota via account settings"],"exampleFix":"// before\n# import fails silently with generic error\n// after\nbegin\n  Canvas::Migration::Worker.download_attachment(cm, url)\nrescue Canvas::Migration::Error => e\n  if e.message =~ /quota/i\n    show_quota_error_dialog\n  end\nend","handlingStrategy":"validation","validationCode":"quota = cm.context.storage_quota\nused = cm.context.storage_quota_used\nraise 'over quota' if used + expected_size > quota","typeGuard":null,"tryCatchPattern":"begin\n  att = Canvas::Migration::Worker.download_attachment(cm, url)\nrescue Canvas::Migration::Error => e\n  raise if e.message !~ /quota/i\n  notify_quota_exceeded(cm.context)\nend","preventionTips":["Check remaining quota before starting large imports","Increase default account quotas for import-heavy workflows","Clean orphaned/unattached files periodically"],"tags":["content-migration","quota","attachment"],"backgroundTag":"file-size-limit-exceeded","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"}