Mintplex-Labs/anything-llm · error

Type must be one of: ${VALID_TYPES.join(", ")}

Error message

Type must be one of: ${VALID_TYPES.join(", ")}

What it means

Validation error propagated from ModelRouterRule.create: the rule's type field is not one of the enumerated VALID_TYPES, so the router cannot interpret the rule and creation is refused with the allowed list.

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. Set the rule type to one of the listed valid types.
  2. Check the VALID_TYPES list in server/endpoints/modelRouter.js.
Defensive patterns

Strategy: validation

When it happens

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

Common situations: Rule creation with a type not in the allowed set.


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