{"record":{"id":"d7bcd7f91c77f5e8","repo":"instructure/canvas-lms","slug":"category-display-name-category-id-didn-t-exist-for-type","errorCode":null,"errorMessage":"#{category_display_name} #{category_id} didn't exist for #{type_display_name(item_type)} #{item_id}.","messagePattern":"#(.+?) #(.+?) didn't exist for #(.+?) #(.+?)\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/group_importer.rb","lineNumber":103,"sourceCode":"\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\"\n            gms = SisBatchRollBackData.build_dependent_data(\n              sis_batch: @batch,\n              contexts: item.group_memberships,\n              updated_state: \"deleted\"\n            )\n            @roll_back_data.push(*gms) if gms","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/group_importer.rb#L85-L121","documentation":"Raised by find_category when no context resolved for the row and the root account's all_<category_type> lookup finds no non-deleted GroupCategory matching the sis_source_id. This is the account-wide variant of the missing-category error.","triggerScenarios":"add_group where context resolution failed, then a group_category_id not matching any category with deleted_at: nil under the root account.","commonSituations":"Soft-deleted categories; category on a different root account/shard; typo'd category id; batch on the wrong root account.","solutions":["Correct the category id to an existing non-deleted one on the root account.","Recreate or restore the category with that sis id before importing.","Process group_categories.csv before groups.csv in the batch.","Verify the batch's root account owns the category."],"exampleFix":"# before\ngroup_id,account_id,group_category_id,name,status\nG101,A100,GC-404,Club,available   # GC-404 deleted/missing\n# after\ngroup_id,account_id,group_category_id,name,status\nG101,A100,GC-1,Club,available","handlingStrategy":"validation","validationCode":"cat = root_account.group_categories.where(deleted_at: nil).find_by(sis_source_id: category_id)\nraise ArgumentError, \"category #{category_id} not found on root account\" 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 not found: #{e.message}\")\nend","preventionTips":["Check deleted_at is nil (soft-deleted categories are skipped)","Confirm the batch's root account matches the data source","Import categories in the same batch before groups","Audit category sis ids after cross-account 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"}