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

search term must be at least #

Error message

search term must be at least #{SearchTermHelper::MIN_SEARCH_TERM_LENGTH} characters

What it means

GraphQL input-object prepare hook validation in AccountUsersFilterInputType. prepare_search_term runs when the search argument is coerced; if the caller passes a term shorter than SearchTermHelper::MIN_SEARCH_TERM_LENGTH, a GraphQL::ExecutionError is raised so the query fails with a clear message instead of running a useless/expensive wildcard search.

Solutions

  1. Lengthen the search term to at least SearchTermHelper::MIN_SEARCH_TERM_LENGTH characters before sending
  2. Have the client validate/hold back short terms until the minimum is met (debounce + length check)
  3. Check SearchTermHelper::MIN_SEARCH_TERM_LENGTH and mirror it in client-side validation

Example fix

// before
users(searchFilter: { search: "ab" }) { ... }
// after
users(searchFilter: { search: "abc" }) { ... }
Defensive patterns

Strategy: validation

Validate before calling

const MIN_SEARCH_TERM_LENGTH = 3 // mirror SearchTermHelper::MIN_SEARCH_TERM_LENGTH
if (term && term.length >= MIN_SEARCH_TERM_LENGTH) runQuery({ search: term })

Type guard

function hasMinLength(term, min) { return typeof term === 'string' && term.length >= min }

Prevention

When it happens

Trigger: Querying account.users with a filter whose search term is present but shorter than MIN_SEARCH_TERM_LENGTH (e.g. search: "ab" when the minimum is 3).

Common situations: UI autocomplete sending partial keystrokes to the GraphQL API; clients not knowing the server-side minimum length; tests hardcoding short search strings.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at app/graphql/types/account_users_filter_input_type.rb:56

           required: false

  argument :include_deleted_users,
           Boolean,
           "Include users with deleted pseudonyms",
           required: false

  argument :temporary_enrollment_recipients,
           Boolean,
           "Only include temporary enrollment recipients",
           required: false

  argument :temporary_enrollment_providers,
           Boolean,
           "Only include temporary enrollment providers",
           required: false

  def prepare_search_term(term)
    if term.present? && term.length < SearchTermHelper::MIN_SEARCH_TERM_LENGTH
      raise GraphQL::ExecutionError,
            "search term must be at least #{SearchTermHelper::MIN_SEARCH_TERM_LENGTH} characters"
    end
    term
  end
end

View on GitHub (pinned to 1c9f0bb801)