{"record":{"id":"cb48a29f8ecde9f6","repo":"Semantic-Org/Semantic-UI","slug":"results-must-be-an-array-to-use-maxresults-setting","errorCode":null,"errorMessage":"Results must be an array to use maxResults setting","messagePattern":"Results must be an array to use maxResults setting","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/definitions/modules/search.js","lineNumber":1306,"sourceCode":"    animating : 'animating',\n    active    : 'active',\n    empty     : 'empty',\n    focus     : 'focus',\n    hidden    : 'hidden',\n    loading   : 'loading',\n    results   : 'results',\n    pressed   : 'down'\n  },\n\n  error : {\n    source          : 'Cannot search. No source used, and Semantic API module was not included',\n    noResults       : 'Your search returned no results',\n    logging         : 'Error in debug logging, exiting.',\n    noEndpoint      : 'No search endpoint was specified',\n    noTemplate      : 'A valid template name was not specified.',\n    oldSearchSyntax : 'searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.',\n    serverError     : 'There was an issue querying the server.',\n    maxResults      : 'Results must be an array to use maxResults setting',\n    method          : 'The method you called is not defined.'\n  },\n\n  metadata: {\n    cache   : 'cache',\n    results : 'results',\n    result  : 'result'\n  },\n\n  regExp: {\n    escape     : /[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g,\n    beginsWith : '(?:\\s|^)'\n  },\n\n  // maps api response attributes to internal representation\n  fields: {\n    categories      : 'results',     // array of categories (category view)\n    categoryName    : 'name',        // name of category (category view)","sourceCodeStart":1288,"sourceCodeEnd":1324,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/modules/search.js#L1288-L1324","documentation":"In generateResults() (search.js:1003-1008), when settings.maxResults > 0 and the response results come back as a plain object (isProperObject) rather than an array, the module cannot slice/limit object results for the 'standard' type, so it logs error.maxResults. Arrays are sliced fine; object-shaped results with maxResults on the standard template are not supported.","triggerScenarios":"settings.type is 'standard', settings.maxResults is set (>0), and the remote/local response returns results as a plain object (e.g. {id:{...}}) instead of an array. The branch at search.js:1004-1007 fires.","commonSituations":"Backend returns a keyed map instead of a list; switching response shape without disabling maxResults; using the standard template with a category-shaped payload.","solutions":["Return results as an array from your endpoint or local source so slicing works.","If you must keep object results, set maxResults: 0 to disable limiting.","Switch type to 'category' if you genuinely need grouped/object data (and handle limiting server-side)."],"exampleFix":"// before: results is an object {1:{...}} with maxResults\n$('.ui.search').search({ type:'standard', maxResults: 5, apiSettings:{ url:'/api?q={query}' } });\n\n// after: endpoint returns an array\n$('.ui.search').search({ type:'standard', maxResults: 5, apiSettings:{ url:'/api?q={query}' } }); // server returns { results: [ ... ] }","handlingStrategy":"type-guard","validationCode":"if (cfg.maxResults > 0 && cfg.type !== 'standard') {\n  // fine for category; for standard ensure array results server-side\n}\nif (cfg.maxResults > 0) console.assert($.isArray(lastResponse), 'Results must be an array for maxResults');","typeGuard":"function resultsAreArray(resp){ return $.isArray(resp && resp.results); }","tryCatchPattern":null,"preventionTips":["Return results as arrays from endpoints.","Set maxResults:0 if your data is object-shaped.","Validate response shape before enabling maxResults."],"tags":["search","max-results","data-shape","semantic-ui","console-error"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}