{"record":{"id":"1322dbf4f048f3f3","repo":"weaviate/weaviate","slug":"query-maximum-results-exceeded-the-total-limit-ca-1322db","errorCode":null,"errorMessage":"query maximum results exceeded: the total limit calculated from the provided offset '%d' and limit '%d' exceeds the configured value for QUERY_MAXIMUM_RESULTS '%d'. If you've supplied a negative offset or limit, this may be an underflow error","messagePattern":"query maximum results exceeded: the total limit calculated from the provided offset '(.+?)' and limit '(.+?)' exceeds the configured value for QUERY_MAXIMUM_RESULTS '(.+?)'\\. If you've supplied a negative offset or limit, this may be an underflow error","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"usecases/objects/get.go","lineNumber":245,"sourceCode":"\treturn int(offset)\n}\n\nfunc (m *Manager) localLimitOrGlobalLimit(offset int64, paramMaxResults *int64) int {\n\tlimit := int64(m.config.Config.QueryDefaults.Limit)\n\t// Get the max results from params, if exists\n\tif paramMaxResults != nil {\n\t\tlimit = *paramMaxResults\n\t}\n\n\treturn int(limit)\n}\n\nfunc (m *Manager) localOffsetLimit(paramOffset *int64, paramLimit *int64) (int, int, error) {\n\toffset := m.localOffsetOrZero(paramOffset)\n\tlimit := m.localLimitOrGlobalLimit(int64(offset), paramLimit)\n\n\tif int64(offset+limit) > m.config.Config.QueryMaximumResults {\n\t\treturn 0, 0, fmt.Errorf(\n\t\t\t\"query maximum results exceeded: the total limit calculated from the provided offset '%d' and limit '%d' exceeds the configured value for QUERY_MAXIMUM_RESULTS '%d'. If you've supplied a negative offset or limit, this may be an underflow error\",\n\t\t\toffset, limit, m.config.Config.QueryMaximumResults)\n\t}\n\n\treturn offset, limit, nil\n}\n\nfunc (m *Manager) trackUsageSingle(res *search.Result) {\n\tif res == nil {\n\t\treturn\n\t}\n\tm.metrics.AddUsageDimensions(res.ClassName, \"get_rest\", \"single_include_vector\", res.Dims)\n}\n\nfunc (m *Manager) trackUsageList(res search.Results) {\n\tif len(res) == 0 {\n\t\treturn\n\t}","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/objects/get.go#L227-L263","documentation":"localOffsetLimit guards the QUERY_MAXIMUM_RESULTS limit: if offset + limit exceeds the configured maximum for a query, the request is rejected with this explanatory message. The note about negative offset/limit exists because integer underflow can inflate the computed total, so a negative input can also trip this check. This is a deliberate guard against unbounded result materialization, not a bug.","triggerScenarios":"GraphQL Get/nearText queries or REST list calls (getObjectsFromRepo / inputs) where client-supplied offset + limit (or a negative value that underflows) exceeds the server's QUERY_MAXIMUM_RESULTS setting.","commonSituations":"Deep pagination with large offsets (offset=100000); client passing limit=-1 expecting 'unlimited'; defaults after upgrading where QUERY_MAXIMUM_RESULTS was lowered; pagination loops that increment offset past the cap.","solutions":["Reduce offset and/or limit so offset+limit stays within QUERY_MAXIMUM_RESULTS","Never send negative limit; paginate with a cursor (GraphQL withLimit/after autoCursor or sort+limit pages) instead of large offsets","Raise QUERY_MAXIMUM_RESULTS in the server config if the workload genuinely needs more results per query","Clamp/validate offset and limit in client code before issuing the query"],"exampleFix":"// before: deep offset pagination\nfor page := 0; ; page++ {\n  offset := page * 100000 // exceeds QUERY_MAXIMUM_RESULTS\n  ...\n}\n// after: bounded cursor pagination\nlimit := int64(100)\nfor {\n  res, _ := queryObjects(ctx, after, limit) // cursor-based, offset always 0\n  if len(res) < int(limit) { break }\n  after = lastCursor(res)\n}","handlingStrategy":"validation","validationCode":"const QUERY_MAXIMUM_RESULTS = 10000;\nfunction assertPagination(offset, limit) {\n  if (offset < 0 || limit <= 0) throw new Error('negative/zero offset or limit');\n  if (offset + limit > QUERY_MAXIMUM_RESULTS) {\n    throw new Error(`offset+limit ${offset+limit} exceeds QUERY_MAXIMUM_RESULTS`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  assertPagination(offset, limit);\n  return await client.graphql.get().withClassName('Article').withOffset(offset).withLimit(limit).do();\n} catch (e) {\n  if (String(e).includes('QUERY_MAXIMUM_RESULTS')) {\n    return paginateWithCursor(e); // fall back to cursor pagination\n  } else throw e;\n}","preventionTips":["Cap client-side pagination depth; use cursor/after-based paging for deep iteration","Never send negative limit expecting 'all results'","Keep offset+limit below QUERY_MAXIMUM_RESULTS (check server config)","Re-check limits after upgrading Weaviate — defaults may change"],"tags":["go","query-limits","pagination"],"backgroundTag":"query-maximum-results-exceeded","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}