Mintplex-Labs/anything-llm · error
Daily message limit must be null or a number greater than…
Error message
Daily message limit must be null or a number greater than or equal to 1
What it means
Thrown when dailyMessageLimit is not null and does not coerce to a number >= 1. null is the sentinel for "no limit"; 0, negatives, NaN-producing strings ("abc"), and the empty string all fail because Number("") is 0. The validator runs before the Prisma write, so the whole update is rejected.
Solutions
- Send null (or omit the field) to remove the limit
- Send an integer >= 1 to set a limit
- Convert empty inputs to null client-side before submitting
- Coerce with Number() and range-check before calling update
Example fix
// before
await user.update(userId, { dailyMessageLimit: "" });
// after
await user.update(userId, { dailyMessageLimit: null }); // or a number >= 1 Defensive patterns
Strategy: validation
Validate before calling
function normalizeLimit(v) {
if (v === null || v === undefined || v === "") return null; // null = unlimited
const n = Number(v);
if (Number.isNaN(n) || n < 1) {
return { error: "Daily message limit must be null or a number >= 1" };
}
return { value: n };
} Type guard
/** @param {unknown} v */
function isValidDailyMessageLimit(v) {
if (v === null) return true;
if (typeof v === "number") return v >= 1;
if (typeof v === "string" && v !== "") {
const n = Number(v);
return !Number.isNaN(n) && n >= 1;
}
return false;
} Try / catch
try {
await user.update(userId, { dailyMessageLimit });
} catch (e) {
if (/Daily message limit/i.test(e.message)) return res.status(400).json({ error: e.message });
throw e;
} Prevention
- Use null for unlimited, never 0
- Convert empty form fields to null before submit
- Set min=1 on the number input and validate client-side
When it happens
Trigger: user.update(userId, { dailyMessageLimit: 0 }) when intending "unlimited"; sending dailyMessageLimit: "" from an empty form input; passing "ten" or "-5"; passing fractional values below 1 such as 0.5.
Common situations: Multi-user admin limit forms that submit empty strings for untouched fields; scripts using 0 as the "no limit" sentinel; string/number coercion surprises from JSON payloads; frontend number inputs allowing 0.
Related errors
- Bio cannot be longer than 1,000 characters
- Invalid role. Allowed roles are
- Username must be at least 2 characters
- Username must start with a lowercase letter and only…
- addToWorkspaces must be a string of comma-separated…
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/e30a468bcd7d7798.
Report an issue: GitHub.
Appendix: source
Thrown at server/models/user.js:64
return username;
} catch (e) {
throw new Error(e.message);
}
},
role: (role = "default") => {
const VALID_ROLES = ["default", "admin", "manager"];
if (!VALID_ROLES.includes(role)) {
throw new Error(
`Invalid role. Allowed roles are: ${VALID_ROLES.join(", ")}`
);
}
return String(role);
},
dailyMessageLimit: (dailyMessageLimit = null) => {
if (dailyMessageLimit === null) return null;
const limit = Number(dailyMessageLimit);
if (isNaN(limit) || limit < 1) {
throw new Error(
"Daily message limit must be null or a number greater than or equal to 1"
);
}
return limit;
},
bio: (bio = "") => {
if (!bio || typeof bio !== "string") return "";
if (bio.length > 1000)
throw new Error("Bio cannot be longer than 1,000 characters");
return String(bio);
},
},
// validations for the above writable fields.
castColumnValue: function (key, value) {
switch (key) {
case "suspended":
return Number(Boolean(value));
case "dailyMessageLimit":View on GitHub (pinned to 3aec848f28)