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

No such outcome for id

Error message

No such outcome for id %{id}

What it means

SetFriendlyDescription mutation raises this when the given outcome_id does not match any ACTIVE LearningOutcome in the database. find_by returns nil for a missing or soft-deleted (workflow_state != active) outcome, and get_outcome converts that nil into a GraphQL::ExecutionError before resolve continues.

Solutions

  1. Verify the outcome id exists and is active: LearningOutcome.active.where(id: id).exists?
  2. If the outcome was deleted, pick a valid outcome id from assignment.learning_outcome_id or the course outcome list
  3. In multi-shard environments, ensure the id is resolved on the outcome's shard

Example fix

// before
outcome = LearningOutcome.active.find_by(id: outcome_id)
raise GraphQL::ExecutionError, "No such outcome" unless outcome
// after
if LearningOutcome.active.where(id: outcome_id).exists?
  SetFriendlyDescription.resolve(outcome_id: outcome_id)
else
  Rails.logger.warn("skipping friendly description: outcome #{outcome_id} missing/inactive")
end
Defensive patterns

Strategy: validation

Validate before calling

// Ruby
def outcome_usable?(outcome_id)
  LearningOutcome.active.where(id: outcome_id).exists?
end

Type guard

// Ruby
outcome = LearningOutcome.active.find_by(id: outcome_id)
return unless outcome.is_a?(LearningOutcome)

Prevention

When it happens

Trigger: Calling setFriendlyDescription with an outcome id that never existed, an id belonging to a deleted outcome, or an id from a different Rails shard/root account.

Common situations: Stale outcome id cached in an older UI page or LTI payload; outcome was deleted by an admin after the page loaded; multi-shard setups where the id is looked up on the wrong shard.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at app/graphql/mutations/set_friendly_description.rb:105

    unless VALID_CONTEXTS.include?(context_type)
      raise GraphQL::ExecutionError, I18n.t("Invalid context type")
    end

    context_type.constantize.find_by(id: context_id).tap do |context|
      unless context
        raise GraphQL::ExecutionError, I18n.t(
          "No such context for %{context_type}#%{context_id}",
          context_type:,
          context_id: context_id.to_s
        )
      end
    end
  end

  def get_outcome(outcome_id)
    LearningOutcome.active.find_by(id: outcome_id).tap do |outcome|
      unless outcome
        raise GraphQL::ExecutionError, I18n.t(
          "No such outcome for id %{id}", { id: outcome_id }
        )
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)