instructure/canvas-lms · error · GraphQL::ExecutionError

Outcome is not available in context #

Error message

Outcome %{outcome_id} is not available in context %{context_type}#%{context_id}

What it means

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.

Solutions

  1. Verify availability first: target_context.available_outcome(outcome_id, allow_global: true) in rails console
  2. Re-list importable outcomes via GraphQL for the target context and use one of those ids
  3. Ensure the outcome's context account is in the target's associated_accounts chain
  4. Confirm the outcome is active (not deleted) and the id is correctly formatted
  5. If the outcome should be importable, import its parent group first so the association chain exists

Example fix

// before
importOutcomes(input: { outcomeId: "999", targetGroupId: "5" }) // not available in target
// after: choose an available outcome
const available = await targetContext.outcomesConnection; 
importOutcomes(input: { outcomeId: available[0].id, targetGroupId: "5" });
Defensive patterns

Strategy: validation

Validate before calling

const outcomes = await targetContext.outcomesConnection;
if (!outcomes.some(o => o.id === outcomeGlobalId)) throw new Error("outcome not available in target context");

Try / catch

try {
  await importOutcomes({ outcomeId, ...target });
} catch (e) {
  if (e.message.includes("is not available in context")) {
    // re-list importable outcomes for the target and retry with a valid id
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/e8be21c2c34670bc. Report an issue: GitHub.

Appendix: source

Thrown at app/graphql/mutations/import_outcomes.rb:101

      # source has to be global or in an associated account
      unless !source_context || target_context.associated_accounts.include?(source_context)
        raise GraphQL::ExecutionError, I18n.t("invalid context for group")
      end

      # source can't be a root group
      if group.learning_outcome_group_id.nil?
        raise GraphQL::ExecutionError, I18n.t("cannot import a root group")
      end

      return process_job(
        source_context:, group:, target_group:
      )
    elsif (outcome_id = input[:outcome_id].presence)
      # Import the selected outcome into the given group

      # verify the outcome is eligible to be linked into the group's context
      unless target_context.available_outcome(outcome_id, allow_global: true)
        raise GraphQL::ExecutionError, I18n.t(
          "Outcome %{outcome_id} is not available in context %{context_type}#%{context_id}",
          outcome_id:,
          context_id: target_context.id.to_s,
          context_type: target_context.class.name
        )
      end

      return process_job(
        source_context:, outcome_id:, target_group:
      )
    end

    validation_error(
      I18n.t("Either groupId or outcomeId values are required")
    )
  end

  class << self

View on GitHub (pinned to 1c9f0bb801)