{"record":{"id":"84b8d0d742fd33c7","repo":"Mintplex-Labs/anything-llm","slug":"ruleupdates-must-be-an-array","errorCode":null,"errorMessage":"ruleUpdates must be an array.","messagePattern":"ruleUpdates must be an array\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/modelRouter.js","lineNumber":147,"sourceCode":"        ModelRouterService.invalidateRouter(routerId);\n        return response.status(200).json({ rule });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500);\n      }\n    }\n  );\n\n  app.put(\n    \"/model-routers/:id/rules/reorder\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { id } = request.params;\n        const { ruleUpdates } = reqBody(request);\n        if (!Array.isArray(ruleUpdates))\n          return response\n            .status(400)\n            .json({ success: false, error: \"ruleUpdates must be an array.\" });\n\n        const { success, error } =\n          await ModelRouterRule.reorderRules(ruleUpdates);\n        if (error) return response.status(400).json({ success, error });\n        ModelRouterService.invalidateRouter(Number(id));\n        return response.status(200).json({ success });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500);\n      }\n    }\n  );\n\n  app.put(\n    \"/model-routers/:id/rules/:ruleId\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/modelRouter.js#L129-L165","documentation":"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.","triggerScenarios":"Thrown at server/endpoints/modelRouter.js:147 when the library encounters an invalid state.","commonSituations":"Bulk rule update called with ruleUpdates that is not an array.","solutions":["Send ruleUpdates as an array of rule update objects.","Verify the request body is valid JSON with the correct shape."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}