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

and cannot be used together

Error message

{a} and {b} cannot be used together

What it means

Raised when both only_student_ids and skip_student_ids are provided to postAssignmentGrades. The two inputs are mutually exclusive filters on visible enrollments; the I18n template interpolates the option names into the message.

Solutions

  1. Send only one of only_student_ids / skip_student_ids; clear the other before submitting.
  2. Compute a single student id list client-side and pass it via only_student_ids.
  3. Server preference impossible here — the API will always reject the combination, so validate in the client.

Example fix

// before
postAssignmentGrades(input: {assignmentId, onlyStudentIds: ["1"], skipStudentIds: ["2"]})
// after
postAssignmentGrades(input: {assignmentId, onlyStudentIds: ["1"]})
Defensive patterns

Strategy: validation

Validate before calling

if (input.onlyStudentIds?.length && input.skipStudentIds?.length)
  throw new Error('only_student_ids and skip_student_ids are mutually exclusive');

Try / catch

try { await post(); } catch (e) { if (/cannot be used together/.test(e.message)) clearExclusiveInputs(); }

Prevention

When it happens

Trigger: postAssignmentGrades with both onlyStudentIds and skipStudentIds arrays present in the input object.

Common situations: UI state accumulation where a selection list (only) and an exclusion list (skip) are both populated from different controls; merging saved filters with current ones.

Related errors


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

Appendix: source

Thrown at app/graphql/mutations/post_assignment_grades.rb:55

      course = assignment.context
      sections = input[:section_ids] ? course.course_sections.where(id: input[:section_ids]) : nil
    rescue ActiveRecord::RecordNotFound
      raise GraphQL::ExecutionError, "not found"
    end

    verify_authorized_action!(assignment, :grade)

    unless assignment.grades_published?
      raise GraphQL::ExecutionError, "Assignments under moderation cannot be posted before grades are published"
    end
    raise GraphQL::ExecutionError, "Anonymous assignments cannot be posted by section" if sections && assignment.anonymous_grading?

    if input[:graded_only] && assignment.anonymous_grading
      raise GraphQL::ExecutionError, "Anonymous assignments cannot be posted by graded only"
    end

    if input[:only_student_ids] && input[:skip_student_ids]
      raise GraphQL::ExecutionError, I18n.t("{a} and {b} cannot be used together", a: "only_student_ids", b: "skip_student_ids")
    end

    visible_enrollments = course.apply_enrollment_visibility(course.student_enrollments, current_user, sections)
    visible_enrollments = visible_enrollments.where(user_id: input[:only_student_ids]) if input[:only_student_ids]
    visible_enrollments = visible_enrollments.where.not(user_id: input[:skip_student_ids]) if input[:skip_student_ids]

    submissions_scope = input[:graded_only] ? assignment.submissions.postable : assignment.submissions
    submissions_scope = submissions_scope.joins(user: :enrollments).merge(visible_enrollments)
    submission_ids = submissions_scope.pluck(:id)
    progress = course.progresses.new(tag: "post_assignment_grades")

    posting_params = {
      graded_only: !!input[:graded_only],
      section_names: sections&.pluck(:name)
    }

    if progress.save
      progress.process_job(

View on GitHub (pinned to 1c9f0bb801)