{"record":{"id":"0cd922aed246492e","repo":"instructure/canvas-lms","slug":"search-term-must-be-at-least-searchtermhelper-min-search-0cd922","errorCode":null,"errorMessage":"search term must be at least #{SearchTermHelper::MIN_SEARCH_TERM_LENGTH} characters","messagePattern":"search term must be at least #(.+?) characters","errorType":"validation","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"warning","filePath":"app/graphql/types/assignment_type.rb","lineNumber":236,"sourceCode":"    class AnonymousStudentIdentityType < ApplicationObjectType\n      description \"An anonymous student identity\"\n\n      field :anonymous_id, ID, null: false\n      field :name, String, null: false\n      field :position, Int, null: false\n    end\n\n    class AssignedStudentsFilterInputType < Types::BaseInputObject\n      graphql_name \"AssignedStudentsFilter\"\n\n      argument :search_term,\n               String,\n               required: false,\n               prepare: :prepare_search_term\n\n      def prepare_search_term(term)\n        if term.presence && term.length < SearchTermHelper::MIN_SEARCH_TERM_LENGTH\n          raise GraphQL::ExecutionError, \"search term must be at least #{SearchTermHelper::MIN_SEARCH_TERM_LENGTH} characters\"\n        end\n\n        term\n      end\n    end\n\n    class AllocationRulesFilterInputType < Types::BaseInputObject\n      argument :search_term,\n               String,\n               required: false,\n               prepare: :prepare_search_term\n\n      def prepare_search_term(term)\n        if term.presence && term.length < SearchTermHelper::MIN_SEARCH_TERM_LENGTH\n          raise GraphQL::ExecutionError, \"search term must be at least #{SearchTermHelper::MIN_SEARCH_TERM_LENGTH} characters\"\n        end\n\n        term","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/types/assignment_type.rb#L218-L254","documentation":"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.","triggerScenarios":"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.","commonSituations":"Client-side search boxes firing on short input; hardcoded short terms in scripts; unawareness of the server minimum length.","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"],"exampleFix":"// before\nsearch: \"jo\"\n// after\nsearch: \"john\"","handlingStrategy":"validation","validationCode":"if (!term || term.length >= MIN_SEARCH_TERM_LENGTH) queryAssignment({ search: term })","typeGuard":"function searchOk(term, min) { return term == null || term.length >= min }","tryCatchPattern":null,"preventionTips":["Validate term length before sending","Debounce autocomplete to avoid keystroke-length terms","Share the min-length constant between client and server"],"tags":["graphql","input-validation","search"],"backgroundTag":"value-out-of-range","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}