{"record":{"id":"9b00a54adeaabb20","repo":"instructure/canvas-lms","slug":"no-institutional-tag-id-given-for-an-institutional-tag-9b00a5","errorCode":null,"errorMessage":"No institutional_tag_id given for an institutional tag","messagePattern":"No institutional_tag_id given for an institutional tag","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/institutional_tag_importer.rb","lineNumber":43,"sourceCode":"      yield importer\n      SisBatchRollBackData.bulk_insert_roll_back_data(importer.roll_back_data)\n      importer.success_count\n    end\n\n    class Work\n      attr_accessor :success_count, :roll_back_data\n\n      def initialize(batch, root_account, logger)\n        @batch = batch\n        @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","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/institutional_tag_importer.rb#L25-L61","documentation":"Raised by SisImports::InstitutionalTagImporter#add_institutional_tag when the tag_id argument is blank. The institutional tag id is the primary identifier used to match existing tags via sis_source_id, so the importer rejects any tag row lacking it before the other field validations. This is the tag-level counterpart of the 'No category_id' check.","triggerScenarios":"Calling add_institutional_tag(tag_id, category_id, name, description, status) with tag_id nil, '' or whitespace; a CSV row in the institutional_tags SIS file with an empty tag id column; a column mapping/scope bug that binds an empty field to tag_id.","commonSituations":"Hand-built or partially regenerated SIS exports where the tag id column is missing; upstream data lacking identifiers for newly added tags; template reordering so the wrong (empty) column feeds tag_id.","solutions":["Populate the institutional_tag_id column for the affected row(s) in the institutional_tags CSV and re-import.","Fix the import mapping/scope so the tag id column is actually passed as tag_id.","If the row is not meant to be imported, remove it from the file rather than leaving the id blank.","Check upstream export tooling so every tag emits a unique, non-empty id."],"exampleFix":"// before\nadd_institutional_tag('', 'cat-1', 'Spring Tag', 'desc', 'active')\n// after\nadd_institutional_tag('tag-101', 'cat-1', 'Spring Tag', 'desc', 'active')","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'tag_id is required' if tag_id.blank?\nadd_institutional_tag(tag_id, category_id, name, description, status)","typeGuard":null,"tryCatchPattern":"begin\n  importer.add_institutional_tag(tag_id, category_id, name, description, status)\nrescue SisImports::ImportError => e\n  Rails.logger.warn(\"Skipping tag #{tag_id}: #{e.message}\")\nend","preventionTips":["Ensure every row in institutional_tags.csv has a non-empty institutional_tag_id.","Drop or fix rows without identifiers before import instead of shipping blanks.","Validate column order/mapping so tag_id is bound to the correct field.","Make upstream exporters guarantee a unique id per tag."],"tags":["sis-import","validation","missing-field","ruby"],"backgroundTag":"empty-required-field","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"}