Mintplex-Labs/anything-llm · error
ruleUpdates must be an array.
Error message
ruleUpdates must be an array.
What it means
Type guard in the PUT /model-routers/:id/rules/reorder endpoint: the request body's ruleUpdates field is not an Array, so the reorder operation has no valid list of {id, priority} updates and is rejected with 400.
Source
Thrown at server/endpoints/modelRouter.js:147
ModelRouterService.invalidateRouter(routerId);
return response.status(200).json({ rule });
} catch (e) {
console.error(e);
response.sendStatus(500);
}
}
);
app.put(
"/model-routers/:id/rules/reorder",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
async (request, response) => {
try {
const { id } = request.params;
const { ruleUpdates } = reqBody(request);
if (!Array.isArray(ruleUpdates))
return response
.status(400)
.json({ success: false, error: "ruleUpdates must be an array." });
const { success, error } =
await ModelRouterRule.reorderRules(ruleUpdates);
if (error) return response.status(400).json({ success, error });
ModelRouterService.invalidateRouter(Number(id));
return response.status(200).json({ success });
} catch (e) {
console.error(e);
response.sendStatus(500);
}
}
);
app.put(
"/model-routers/:id/rules/:ruleId",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
async (request, response) => {View on GitHub (pinned to 3aec848f28)
Solutions
- Send ruleUpdates as an array of rule update objects.
- Verify the request body is valid JSON with the correct shape.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/endpoints/modelRouter.js:147 when the library encounters an invalid state.
Common situations: Bulk rule update called with ruleUpdates that is not an array.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/84b8d0d742fd33c7.
Report an issue: GitHub.