{"record":{"id":"8e593cbff66e1aff","repo":"instructure/canvas-lms","slug":"cannot-import-a-root-group","errorCode":null,"errorMessage":"cannot import a root group","messagePattern":"cannot import a root group","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/import_outcomes.rb","lineNumber":90,"sourceCode":"      if group.nil?\n        raise GraphQL::ExecutionError, I18n.t(\"group not found\")\n      end\n\n      # If optional source context provided, then check that\n      # matches the group's context\n      source_context ||= group.context\n      if source_context && source_context != group.context\n        raise GraphQL::ExecutionError, I18n.t(\"source context does not match group context\")\n      end\n\n      # source has to be global or in an associated account\n      unless !source_context || target_context.associated_accounts.include?(source_context)\n        raise GraphQL::ExecutionError, I18n.t(\"invalid context for group\")\n      end\n\n      # source can't be a root group\n      if group.learning_outcome_group_id.nil?\n        raise GraphQL::ExecutionError, I18n.t(\"cannot import a root group\")\n      end\n\n      return process_job(\n        source_context:, group:, target_group:\n      )\n    elsif (outcome_id = input[:outcome_id].presence)\n      # Import the selected outcome into the given group\n\n      # verify the outcome is eligible to be linked into the group's context\n      unless target_context.available_outcome(outcome_id, allow_global: true)\n        raise GraphQL::ExecutionError, I18n.t(\n          \"Outcome %{outcome_id} is not available in context %{context_type}#%{context_id}\",\n          outcome_id:,\n          context_id: target_context.id.to_s,\n          context_type: target_context.class.name\n        )\n      end\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/import_outcomes.rb#L72-L108","documentation":"ImportOutcomes raises this when the requested source group is a root outcome group (learning_outcome_group_id is nil) — i.e. the top-level container for a context's outcomes. Root groups represent the whole context's outcome library and cannot be imported as a group; import individual outcomes instead.","triggerScenarios":"Calling importOutcomes with groupId set to a context's root outcome group id (the id often returned by context.rootOutcomeGroup); passing an account's or course's top-level group fetched from the outcomes UI root.","commonSituations":"Selecting 'All outcomes' / the root folder in the UI and importing it; using target_context.root_outcome_group.id as the source groupId; assuming root groups are importable like normal folders.","solutions":["Import individual outcomes with outcomeId instead of the root groupId","Use a non-root child group (learning_outcome_group_id not nil) as groupId","Check the group: LearningOutcomeGroup.find(id).learning_outcome_group_id — if nil it is a root group and cannot be imported","Enumerate child_outcome_groups.active of the root group and import those"],"exampleFix":"// before: root group\nimportOutcomes(input: { groupId: account.rootOutcomeGroup.id, targetGroupId: \"5\" })\n// after: import a child group or individual outcomes\nimportOutcomes(input: { groupId: account.rootOutcomeGroup.childGroups[0].id, targetGroupId: \"5\" });","handlingStrategy":"validation","validationCode":"const g = await graphqlClient.node(toGlobalId(\"LearningOutcomeGroup\", groupId));\nif (g.parentOutcomeGroup == null) throw new Error(\"cannot import a root group — pick a child group or individual outcomes\");","typeGuard":"const isImportableGroup = (g) => g && g.parentOutcomeGroup != null;","tryCatchPattern":"try {\n  await importOutcomes({ groupId, ...target });\n} catch (e) {\n  if (e.message === \"cannot import a root group\") {\n    // switch to outcomeId-based import or select a child group\n  }\n}","preventionTips":["Disable the root group as an import source in the UI (check parentOutcomeGroup)","Import child groups or individual outcomes instead of the library root","Remember context.rootOutcomeGroup is a container, not an importable unit"],"tags":["graphql","validation","unsupported-operation","canvas-lms"],"backgroundTag":"unsupported-operation","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"}