{"record":{"id":"450ce17ab330aad9","repo":"instructure/canvas-lms","slug":"category-display-name-category-id-didn-t-exist-in-context","errorCode":null,"errorMessage":"#{category_display_name} #{category_id} didn't exist in #{context_name} #{context.sis_source_id} for #{type_display_name(item_type)} #{item_id}.","messagePattern":"#(.+?) #(.+?) didn't exist in #(.+?) #(.+?) for #(.+?) #(.+?)\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_importer.rb","lineNumber":97,"sourceCode":"\n        context\n      end\n\n      def find_category(category_id, context, category_type, item_type, item_id)\n        return nil unless category_id.present?\n\n        category_display_name = if category_type.to_s == \"differentiation_tag_category\"\n                                  \"Differentiation Tag Set\"\n                                else\n                                  \"Group Category\"\n                                end\n\n        category = nil\n        if context\n          category = context.send(category_type.to_s.pluralize).find_by(sis_source_id: category_id)\n          unless category\n            context_name = context.class.name.downcase\n            raise ImportError, \"#{category_display_name} #{category_id} didn't exist in #{context_name} #{context.sis_source_id} for #{type_display_name(item_type)} #{item_id}.\"\n          end\n        else\n          method_name = \"all_#{category_type.to_s.pluralize}\"\n          category = @root_account.send(method_name).find_by(deleted_at: nil, sis_source_id: category_id)\n          unless category\n            raise ImportError, \"#{category_display_name} #{category_id} didn't exist for #{type_display_name(item_type)} #{item_id}.\"\n          end\n        end\n\n        category\n      end\n\n      def save_and_process_memberships(item, item_type, status)\n        if item.save\n          data = SisBatchRollBackData.build_data(sis_batch: @batch, context: item)\n          @roll_back_data << data if data\n\n          if status == \"deleted\"","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_importer.rb#L79-L115","documentation":"Raised by find_category when a group_category_id/tag_set_id is given, a context (course or account) resolved, but no GroupCategory with that sis_source_id exists within that context. The message includes the category id, the context class name and sis id, and the item id.","triggerScenarios":"add_group/add_tag with a category id whose sis_source_id does not exist under the resolved course/account — e.g. a category defined at account level referenced from a course-scoped row.","commonSituations":"Category sis ids changed between terms; copying group CSVs across courses without remapping categories; importing group_categories.csv after groups.csv; cross-context id reuse.","solutions":["Fix the category id to one defined in the same course/account context.","Import group_categories.csv before groups.csv.","Reference account-level categories only from account-scoped rows.","Create the missing GroupCategory with the correct sis_source_id first."],"exampleFix":"# before (GC-1 exists only on account, row is course-scoped)\ngroup_id,course_id,group_category_id,name,status\nG101,C200,GC-1,Study Group A,available\n# after\ngroup_id,course_id,group_category_id,name,status\nG101,C200,CAT-C200-1,Study Group A,available","handlingStrategy":"validation","validationCode":"ctx = root_account.all_courses.active.find_by(sis_source_id: course_id)\ncat = ctx&.group_categories&.find_by(sis_source_id: category_id)\nraise ArgumentError, \"category #{category_id} missing in course #{course_id}\" unless cat","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_group(gid, cat_id, acct_id, course_id, name, status)\nrescue ImportError => e\n  logger.warn(\"Category resolution failed: #{e.message}\")\nend","preventionTips":["Import group_categories.csv before groups.csv","Scope category ids to the same context as the group row","Never reuse account-level category ids in course rows","Verify category sis ids survive migrations"],"tags":["sis-import","resource-not-found","group-category"],"backgroundTag":"resource-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"}