{"record":{"id":"9d8a4e4056f053cc","repo":"instructure/canvas-lms","slug":"group-with-id-guid-already-exists-in-another-unrelated","errorCode":null,"errorMessage":"Group with ID %{guid} already exists in another unrelated course or account (%{name})","messagePattern":"Group with ID %(.+?) already exists in another unrelated course or account \\(%(.+?)\\)","errorType":"exception","errorClass":"InvalidDataError","httpStatus":null,"severity":"error","filePath":"lib/outcomes/import.rb","lineNumber":108,"sourceCode":"        if group_context.nil?\n          raise InvalidDataError, I18n.t(\n            \"Course with canvas id %{id} not found\",\n            id: group[:course_id]\n          )\n        end\n\n        unless child_context?(group_context)\n          raise InvalidDataError, I18n.t(\n            \"Target course %{course_id} is not a child of current account (%{name})\",\n            course_id: group[:course_id],\n            name: context.name\n          )\n        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]","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/outcomes/import.rb#L90-L126","documentation":"find_prior_group locates an existing LearningOutcomeGroup by vendor_guid (falling back across contexts). If the found group's context is not the target group_context, the guid is already used by an unrelated course/account, and the import raises this error instead of hijacking or duplicating that group. The message includes the owning context's name.","triggerScenarios":"Importing a group whose vendor_guid matches a group that already lives in a different course or account; reusing global vendor_guids (e.g. 'group-1') across multiple courses; a group was moved/merged since the mapping was made.","commonSituations":"CSVs exported from one account replayed into another; template courses cloned where each copy kept the same vendor_guids; test data with placeholder guids colliding with real records.","solutions":["Use unique vendor_guids per context — prefix or namespace them (e.g. 'myorg.math.group1').","Import into the context that already owns the group with that guid, or the account that can see it.","Delete/rename the conflicting group first, or pick a new vendor_guid for the imported group.","If the existing group is in a related context your account owns, verify how find_prior_group resolves guids and adjust the import context accordingly."],"exampleFix":"// before\n{ object_type: 'group', vendor_guid: 'group-1' } # already used in Course A\n// after\n{ object_type: 'group', vendor_guid: 'dept-b.group-1' }","handlingStrategy":"validation","validationCode":"existing = LearningOutcomeGroup.where(vendor_guid: guids).joins(:context)\nconflicts = existing.select { |g| g.context_id != target_context.id }\nraise ArgumentError, \"guids owned elsewhere: #{conflicts.map(&:vendor_guid)}\" if conflicts.any?","typeGuard":null,"tryCatchPattern":"begin\n  importer.import_group(group)\nrescue Outcomes::Import::InvalidDataError => e\n  failures << {vendor_guid: group[:vendor_guid], error: e.message}\nend","preventionTips":["Namespace vendor_guids per source/context","Preflight guid collisions against existing groups in target context","Never reuse template or demo guids in production data"],"tags":["conflict","identifier","uniqueness","outcomes-import"],"backgroundTag":"invalid-identifier","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"}