Mintplex-Labs/anything-llm · error

A rule with that priority already exists on this router.

Error message

A rule with that priority already exists on this router.

What it means

Uniqueness violation from ModelRouterRule.create: another rule on the same router already claims the submitted priority value, and since priority determines evaluation order, duplicates are rejected.

Source

Thrown at server/endpoints/modelRouter.js:126

      }
    }
  );

  app.post(
    "/model-routers/:id/rules/new",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const { id } = request.params;
        const user = await userFromSession(request, response);
        const data = reqBody(request);
        const routerId = Number(id);
        const { rule, error } = await ModelRouterRule.create(
          routerId,
          data,
          user?.id || null
        );
        if (error) return response.status(400).json({ rule, error });

        await Telemetry.sendTelemetry("model_router_rule_created");
        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);

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Assign a different priority number to the rule.
  2. Check existing rule priorities on this router.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/endpoints/modelRouter.js:126 when the library encounters an invalid state.

Common situations: A rule with the same priority already exists on the router.


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/689b32b423e54ce0. Report an issue: GitHub.