{"record":{"id":"300e3f0d27d0af0d","repo":"instructure/canvas-lms","slug":"category-with-id-category-id-didn-t-exist-for-institutional","errorCode":null,"errorMessage":"Category with id \"#{category_id}\" didn't exist for institutional tag #{tag_id}","messagePattern":"Category with id \"#(.+?)\" didn't exist for institutional tag #(.+?)","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/institutional_tag_importer.rb","lineNumber":53,"sourceCode":"        @root_account = root_account\n        @logger = logger\n        @success_count = 0\n        @roll_back_data = []\n        @categories_cache = {}\n      end\n\n      def add_institutional_tag(tag_id, category_id, name, description, status)\n        raise ImportError, \"No institutional_tag_id given for an institutional tag\" if tag_id.blank?\n        raise ImportError, \"No category_id given for institutional tag #{tag_id}\" if category_id.blank?\n        raise ImportError, \"No name given for institutional tag #{tag_id}\" if name.blank?\n        raise ImportError, \"No description given for institutional tag #{tag_id}\" if description.blank?\n        raise ImportError, \"No status given for institutional tag #{tag_id}\" if status.blank?\n        raise ImportError, \"Improper status \\\"#{status}\\\" for institutional tag #{tag_id}\" unless /\\A(active|deleted)/i.match?(status)\n        return if @batch.skip_deletes? && /deleted/i.match?(status)\n\n        category = @categories_cache[category_id]\n        category ||= InstitutionalTagCategory.find_by(root_account_id: @root_account.id, sis_source_id: category_id)\n        raise ImportError, \"Category with id \\\"#{category_id}\\\" didn't exist for institutional tag #{tag_id}\" unless category\n\n        @categories_cache[category_id] = category\n\n        tag = InstitutionalTag.find_by(root_account_id: @root_account.id, sis_source_id: tag_id)\n        tag ||= InstitutionalTag.new(category:,\n                                     root_account: @root_account,\n                                     sis_source_id: tag_id)\n\n        tag.name = name\n        tag.description = description\n        tag.sis_batch_id = @batch.id\n        tag.workflow_state = /deleted/i.match?(status) ? \"deleted\" : \"active\"\n\n        if tag.save\n          data = SisBatchRollBackData.build_data(sis_batch: @batch, context: tag)\n          @roll_back_data << data if data\n          @success_count += 1\n          maybe_write_roll_back_data","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/institutional_tag_importer.rb#L35-L71","documentation":"Guard in SIS::InstitutionalTagImporter::Work#add_institutional_tag: the referenced category (by sis category_id) was not found for the root account, so ImportError is raised — the tag row references a category that doesn't exist.","triggerScenarios":"Thrown at lib/sis/institutional_tag_importer.rb:53 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Import the category first (same or earlier batch) before tags referencing it","Verify the category_id spelling matches the category's sis id"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}