Budibase/budibase · error · HTTPError
Invalid status query
Error message
Invalid status query
What it means
Thrown by sanitizeStatusQuery when the `status` query parameter is not a member of AGENT_REQUEST_STATUSES. The value is checked against the allowed AgentRequestStatus enum; unknown statuses are rejected with this 400 error rather than silently returning no results.
Source
Thrown at packages/server/src/api/controllers/ai/agentRequests.ts:59
if (parsedPage < 1) {
throw new HTTPError("Page query must be greater than 0", 400)
}
return parsedPage
}
const sanitizeStatusQuery = (
status?: string
): AgentRequestStatus | undefined => {
const normalizedStatus = status?.trim()
if (!normalizedStatus) {
return undefined
}
if (
!AGENT_REQUEST_STATUSES.includes(normalizedStatus as AgentRequestStatus)
) {
throw new HTTPError("Invalid status query", 400)
}
return normalizedStatus as AgentRequestStatus
}
export async function fetchAgentRequests(
ctx: UserCtx<void, FetchAgentRequestsResponse>
) {
const { limit, page, status } = ctx.query as Record<string, string>
const resolvedLimit = sanitizeLimitQuery(limit)
const resolvedPage = sanitizePageQuery(page)
const resolvedStatus = sanitizeStatusQuery(status)
const [requests, summary] = await Promise.all([
sdk.ai.agentRequests.fetchRequests({
limit: resolvedLimit,
page: resolvedPage,
status: resolvedStatus,
}),View on GitHub (pinned to a81a902e9a)
Solutions
- Use one of the exact AGENT_REQUEST_STATUSES values (check the AgentRequestStatus type in the codebase for the list)
- Match casing exactly as defined by the enum
- Remove the status filter to fetch all statuses
- Update client filter options to stay in sync with the server enum after renames
Example fix
// before ?status=Complete // after ?status=complete // must match AgentRequestStatus exactly
Defensive patterns
Strategy: validation
Validate before calling
const AGENT_REQUEST_STATUSES = ["success", "error"] // check AgentRequestStatus in @budibase/types for exact values
function validateStatus(status) {
if (status !== undefined && !AGENT_REQUEST_STATUSES.includes(status)) {
throw new Error(`status must be one of: ${AGENT_REQUEST_STATUSES.join(", ")}`)
}
return status
}
validateStatus(searchParams.get("status")) Type guard
function isAgentRequestStatus(v) {
return AGENT_REQUEST_STATUSES.includes(v)
} Try / catch
try {
return await fetchAgentRequests(agentId, { status })
} catch (err) {
if (err.status === 400 && err.message === "Invalid status query") {
return fetchAgentRequests(agentId, { status: undefined }) // no filter
}
throw err
} Prevention
- Import the AgentRequestStatus type/enum from @budibase/types instead of hardcoding strings
- Keep client filter dropdown options generated from the same enum the server uses
- Treat status comparisons as case-sensitive
- Handle 'all' pseudo-values client-side by omitting the status param
When it happens
Trigger: GET agent requests with ?status=FAILED, ?status=complete, ?status=cancelled or any other value not exactly matching an entry in AGENT_REQUEST_STATUSES (case-sensitive membership check).
Common situations: Frontend filter dropdowns whose options drifted from the backend enum; users pasting status text with different casing; older client versions using renamed status values after an API change; generic UI components passing 'all' or 'any' pseudo-values.
Related errors
- Invalid environment query
- startDate query must be before endDate query
- Invalid limit query
- Limit query must be between 1 and 100
- Invalid page query
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/7e4724a8823c1b28.
Report an issue: GitHub.