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
AssignmentType's search argument prepare hook. Any assignment-related connection queried with a non-blank search term shorter than SearchTermHelper::MIN_SEARCH_TERM_LENGTH raises GraphQL::ExecutionError during argument preparation, rejecting too-short search inputs before the DB query runs.
Solutions
- Send a search term of at least SearchTermHelper::MIN_SEARCH_TERM_LENGTH characters
- Validate the term length client-side before issuing the query
- Omit the search argument entirely instead of passing a too-short string
Example fix
// before search: "jo" // after search: "john"
Defensive patterns
Strategy: validation
Validate before calling
if (!term || term.length >= MIN_SEARCH_TERM_LENGTH) queryAssignment({ search: term }) Type guard
function searchOk(term, min) { return term == null || term.length >= min } Prevention
- Validate term length before sending
- Debounce autocomplete to avoid keystroke-length terms
- Share the min-length constant between client and server
When it happens
Trigger: Querying an assignment connection field that declares prepare: :prepare_search_term (e.g. submissions with a student search) with a present but under-length search string.
Common situations: Client-side search boxes firing on short input; hardcoded short terms in scripts; unawareness of the server minimum length.
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
- search term must be at least #
- search term must be at least #
- and cannot be used together
- and cannot be used together
- Anonymous assignments cannot be posted by graded only
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/0cd922aed246492e.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/types/assignment_type.rb:236
class AnonymousStudentIdentityType < ApplicationObjectType
description "An anonymous student identity"
field :anonymous_id, ID, null: false
field :name, String, null: false
field :position, Int, null: false
end
class AssignedStudentsFilterInputType < Types::BaseInputObject
graphql_name "AssignedStudentsFilter"
argument :search_term,
String,
required: false,
prepare: :prepare_search_term
def prepare_search_term(term)
if term.presence && 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
class AllocationRulesFilterInputType < Types::BaseInputObject
argument :search_term,
String,
required: false,
prepare: :prepare_search_term
def prepare_search_term(term)
if term.presence && term.length < SearchTermHelper::MIN_SEARCH_TERM_LENGTH
raise GraphQL::ExecutionError, "search term must be at least #{SearchTermHelper::MIN_SEARCH_TERM_LENGTH} characters"
end
termView on GitHub (pinned to 1c9f0bb801)