Budibase/budibase · error · HTTPError
Limit query must be between 1 and 100
Error message
Limit query must be between 1 and 100
What it means
Thrown by sanitizeLimitQuery when the limit is numeric but outside the allowed range. The library clamps valid requests to between 1 and 100 inclusive; parsed values below 1 or above 100 are rejected with this 400 error.
Source
Thrown at packages/server/src/api/controllers/ai/agentRequests.ts:24
type UserCtx,
} from "@budibase/types"
import sdk from "../../../sdk"
const DEFAULT_LIMIT = 100
const sanitizeLimitQuery = (limit?: string): number => {
const normalizedLimit = limit?.trim()
if (!normalizedLimit) {
return DEFAULT_LIMIT
}
if (!/^\d+$/.test(normalizedLimit)) {
throw new HTTPError("Invalid limit query", 400)
}
const parsedLimit = Number.parseInt(normalizedLimit, 10)
if (parsedLimit < 1 || parsedLimit > 100) {
throw new HTTPError("Limit query must be between 1 and 100", 400)
}
return parsedLimit
}
const sanitizePageQuery = (page?: string): number => {
const normalizedPage = page?.trim()
if (!normalizedPage) {
return 1
}
if (!/^\d+$/.test(normalizedPage)) {
throw new HTTPError("Invalid page query", 400)
}
const parsedPage = Number.parseInt(normalizedPage, 10)
if (parsedPage < 1) {
throw new HTTPError("Page query must be greater than 0", 400)View on GitHub (pinned to a81a902e9a)
Solutions
- Use a limit between 1 and 100, e.g. ?limit=100
- Omit the limit parameter to use DEFAULT_LIMIT
- Clamp the value client-side: Math.min(100, Math.max(1, value))
- Page through results using the page/bookmark parameters instead of raising limit
Example fix
// before ?limit=500 // after ?limit=100
Defensive patterns
Strategy: validation
Validate before calling
function clampLimit(limit, { min = 1, max = 100 } = {}) {
const n = Number.parseInt(String(limit), 10)
if (Number.isNaN(n)) return undefined
return Math.min(max, Math.max(min, n))
}
clampLimit(searchParams.get("limit")) Type guard
function isLimitInRange(v) {
return typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= 100
} Try / catch
try {
return await fetchAgentRequests(agentId, { limit })
} catch (err) {
if (err.status === 400 && err.message === "Limit query must be between 1 and 100") {
return fetchAgentRequests(agentId, { limit: 100 })
}
throw err
} Prevention
- Clamp page-size values to 1-100 in the UI component itself
- Do not attempt to 'fetch all' with a giant limit; use pagination
- Align client defaults with the server's documented maximum
- Add client-side validation mirroring server rules
When it happens
Trigger: GET agent requests with ?limit=0, ?limit=-3, or ?limit=500. Values like 101+ are digits so pass the regex but fail the range check.
Common situations: 'Fetch everything' attempts using very large limits; UI spinners allowing 0 or negative page sizes; defaults copied from another API with different maxima; attempts to disable pagination by passing a huge limit.
Related errors
- Invalid limit query
- Invalid page query
- Invalid bookmark query
- Invalid limit query
- Limit query must be between 1 and 100
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/8233eafe38451553.
Report an issue: GitHub.