{"record":{"id":"3aa3a7bc41f2bd1f","repo":"instructure/canvas-lms","slug":"group-guid-has-already-appeared-in-this-import","errorCode":null,"errorMessage":"Group \"%{guid}\" has already appeared in this import","messagePattern":"Group \"%(.+?)\" has already appeared in this import","errorType":"exception","errorClass":"InvalidDataError","httpStatus":null,"severity":"error","filePath":"lib/outcomes/import.rb","lineNumber":121,"sourceCode":"        end\n      end\n\n      model = find_prior_group(group, group_context)\n      unless model.context == group_context\n        raise InvalidDataError, I18n.t(\n          \"Group with ID %{guid} already exists in another unrelated course or account (%{name})\",\n          guid: group[:vendor_guid],\n          name: model.context.name\n        )\n      end\n\n      parents = find_parents(group, group_context, model:)\n      raise InvalidDataError, I18n.t(\"An outcome group can only have one parent\") if parents.length > 1\n\n      parent = parents.first\n\n      if model.outcome_import_id == outcome_import_id\n        raise InvalidDataError, I18n.t(\n          'Group \"%{guid}\" has already appeared in this import',\n          guid: group[:vendor_guid]\n        )\n      end\n      model.vendor_guid = group[:vendor_guid]\n      model.title = group[:title]\n      model.description = group[:description] || \"\"\n      model.workflow_state = group[:workflow_state].presence || \"active\"\n      model.learning_outcome_group = parent\n      model.outcome_import_id = outcome_import_id\n      model.save!\n\n      if model.workflow_state == \"deleted\"\n        model.destroy!\n      end\n\n      model\n    end","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/outcomes/import.rb#L103-L139","documentation":"After a group is imported its outcome_import_id is stamped with the current import. If the same vendor_guid appears again within the same import batch, import_group detects model.outcome_import_id == outcome_import_id and raises this error to prevent processing the same group twice in one run. Each group must appear at most once per import.","triggerScenarios":"A CSV/JSON import containing two rows with object_type 'group' and identical vendor_guid; the same group guid listed both as a definition and later as a re-parent update in the same file.","commonSituations":"Merged spreadsheets with duplicated rows; concatenating two export files that share guids; generator bugs emitting a group each time it is referenced as a parent.","solutions":["Deduplicate rows by vendor_guid before running the import, keeping the last/most complete row.","Remove the second occurrence and, if re-parenting was intended, do it in a separate later import.","Fix the generator so a parent group is emitted only once even when referenced multiple times."],"exampleFix":"// before\nrows = [g(vendor_guid: 'g1'), g(vendor_guid: 'g1')]\n// after\nrows = rows.uniq { |r| r[:vendor_guid] }","handlingStrategy":"validation","validationCode":"guids = rows.select { |r| r[:object_type] == 'group' }.map { |r| r[:vendor_guid] }\nraise ArgumentError, \"duplicate group rows\" if guids.uniq.size != guids.size","typeGuard":null,"tryCatchPattern":"begin\n  importer.import_object(row)\nrescue Outcomes::Import::InvalidDataError => e\n  skipped << {vendor_guid: row[:vendor_guid], error: e.message}\nend","preventionTips":["Uniq batch rows by vendor_guid before import","Emit parent groups only once even when referenced repeatedly","Deduplicate when concatenating multiple export files"],"tags":["duplicate","conflict","batch","outcomes-import"],"backgroundTag":"file-already-exists","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"}