{"record":{"id":"57a80e37ada06fb6","repo":"instructure/canvas-lms","slug":"account-with-id-account-id-didn-t-exist-for-type-display-sis","errorCode":null,"errorMessage":"Account with id \"#{account_id}\" didn't exist for #{type_display} #{sis_id}","messagePattern":"Account with id \"#(.+?)\" didn't exist for #(.+?) #(.+?)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_category_importer.rb","lineNumber":63,"sourceCode":"        raise ImportError, \"No sis_id given for a #{type_display}\" if sis_id.blank?\n        raise ImportError, \"No name given for #{type_display} #{sis_id}\" if name.blank?\n        raise ImportError, \"No status given for #{type_display} #{sis_id}\" if status.blank?\n        raise ImportError, \"Improper status \\\"#{status}\\\" for #{type_display} #{sis_id}, skipping\" unless /\\A(active|deleted)/i.match?(status)\n        return true if @batch.skip_deletes? && status =~ /deleted/i\n\n        false\n      end\n\n      def find_context(account_id, course_id, sis_id, type_display)\n        context = nil\n        if account_id && course_id\n          raise ImportError, \"Only one context is allowed and both course_id and account_id where provided for #{type_display} #{sis_id}.\"\n        end\n\n        if account_id\n          context = @accounts_cache[account_id]\n          context ||= @root_account.all_accounts.active.find_by(sis_source_id: account_id)\n          raise ImportError, \"Account with id \\\"#{account_id}\\\" didn't exist for #{type_display} #{sis_id}\" unless context\n\n          @accounts_cache[context.sis_source_id] = context\n        end\n\n        if course_id\n          context = @courses_cache[course_id]\n          context ||= @root_account.all_courses.active.find_by(sis_source_id: course_id)\n          raise ImportError, \"Course with id \\\"#{course_id}\\\" didn't exist for #{type_display} #{sis_id}\" unless context\n\n          @courses_cache[context.sis_source_id] = context\n        elsif course_id.nil? && type_display == \"differentiation tag set\"\n          raise ImportError, \"No course_id given for #{type_display} #{sis_id}\"\n        end\n\n        context || @root_account\n      end\n\n      def check_context_movement(category, context, sis_id, type_display)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_category_importer.rb#L45-L81","documentation":"find_context looks up an Account by sis_source_id (@root_account.all_accounts.active.find_by). When the account_id in the row matches no active account under the root account, the importer has no context to attach the group category/tag to and raises ImportError.","triggerScenarios":"add_group_category / add_group / add_tag / add_differentiation_tag_set called with an account_id whose sis_source_id does not exist, is soft-deleted, or belongs to a different root account.","commonSituations":"Stale SIS data: the account was deleted or its sis_source_id renamed after the CSV was generated; cross-instance imports where IDs from another Canvas instance are used; typo in the account's SIS ID; account is inactive ('active' scope filters it out).","solutions":["Verify the account_id matches an existing account's sis_source_id under the importing root account (check accounts table).","Re-export the CSV from the current Canvas state so IDs are fresh.","If the account was intentionally deleted, remove or correct dependent rows in the import.","Check the account is active (not soft-deleted), since lookup uses .active."],"exampleFix":"// before\ngc-1,Math Groups,ACCT-TYPO,,active\n// after (existing sis_source_id)\ngc-1,Math Groups,ACCT-123,,active","handlingStrategy":"try-catch","validationCode":"unless Account.active.where(root_account_id: root_account.id, sis_source_id: account_id).exists?\n  raise ArgumentError, \"account #{account_id} not found under root account\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_group_category(sis_id, account_id, nil, name, status)\nrescue SIS::GroupCategoryImporter::ImportError => e\n  if e.message =~ /Account with id/ then skip_row(sis_id, e.message)\n  else raise end\nend","preventionTips":["Re-export SIS data from the same Canvas instance/shard you import into","Pre-verify all referenced sis_source_ids exist and are active","Keep account sis_source_ids stable; avoid renaming them"],"tags":["sis","csv-import","record-lookup","foreign-key"],"backgroundTag":"record-not-found","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"}