{"record":{"id":"e8be21c2c34670bc","repo":"instructure/canvas-lms","slug":"outcome-outcome-id-is-not-available-in-context-context-type","errorCode":null,"errorMessage":"Outcome %{outcome_id} is not available in context %{context_type}#%{context_id}","messagePattern":"Outcome %(.+?) is not available in context %(.+?)#%(.+?)","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/import_outcomes.rb","lineNumber":101,"sourceCode":"      # 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\n      return process_job(\n        source_context:, outcome_id:, target_group:\n      )\n    end\n\n    validation_error(\n      I18n.t(\"Either groupId or outcomeId values are required\")\n    )\n  end\n\n  class << self","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/import_outcomes.rb#L83-L119","documentation":"ImportOutcomes raises this when target_context.available_outcome(outcome_id, allow_global: true) returns false — the outcomeId is not available (not defined in, associated to, or importable into) the target Account/Course context. Global outcomes are allowed, but the outcome must still be resolvable for the target context.","triggerScenarios":"Calling importOutcomes with an outcomeId that exists only in an unassociated account, was deleted, belongs to a course not visible to the target, or whose id does not resolve on the target's shard; also typo'd/wrong-type ids.","commonSituations":"Importing an outcome from an unrelated account tree; soft-deleted outcomes; cross-shard outcome ids; outcome only linked in the source course; UI caches listing outcomes the target context cannot actually access.","solutions":["Verify availability first: target_context.available_outcome(outcome_id, allow_global: true) in rails console","Re-list importable outcomes via GraphQL for the target context and use one of those ids","Ensure the outcome's context account is in the target's associated_accounts chain","Confirm the outcome is active (not deleted) and the id is correctly formatted","If the outcome should be importable, import its parent group first so the association chain exists"],"exampleFix":"// before\nimportOutcomes(input: { outcomeId: \"999\", targetGroupId: \"5\" }) // not available in target\n// after: choose an available outcome\nconst available = await targetContext.outcomesConnection; \nimportOutcomes(input: { outcomeId: available[0].id, targetGroupId: \"5\" });","handlingStrategy":"validation","validationCode":"const outcomes = await targetContext.outcomesConnection;\nif (!outcomes.some(o => o.id === outcomeGlobalId)) throw new Error(\"outcome not available in target context\");","typeGuard":null,"tryCatchPattern":"try {\n  await importOutcomes({ outcomeId, ...target });\n} catch (e) {\n  if (e.message.includes(\"is not available in context\")) {\n    // re-list importable outcomes for the target and retry with a valid id\n  }\n}","preventionTips":["List outcomes from the TARGET context, not the source, when building pickers","Verify the outcome is active and its account is associated with the target","Mind cross-shard/global id formats","Import the parent group first when an outcome's association chain is missing"],"tags":["graphql","validation","outcomes","canvas-lms"],"backgroundTag":"resource-not-found","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"}