Mintplex-Labs/anything-llm · error · Error
Daily message limit must be null or a number greater than or
Error message
Daily message limit must be null or a number greater than or equal to 1
What it means
Thrown by User.validations.dailyMessageLimit when the value is non-null but Number(value) is NaN or less than 1. null is explicitly allowed (means 'no limit'). The validator runs in User.create (line 133) and the value is cast via castColumnValue for storage.
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 526360e320)
Solutions
- Pass null (or omit the field, since the default is null) to mean 'no limit'.
- Pass an integer >= 1 to set a cap.
- Coerce ambiguous inputs: treat 0/empty as null before validation.
Example fix
// before
User.create({ username, password, dailyMessageLimit: 0 });
// after
User.create({ username, password, dailyMessageLimit: null }); Defensive patterns
Strategy: validation
Validate before calling
function normalizeDailyLimit(v) {
if (v === null || v === '' || v === undefined) return null;
const n = Number(v);
if (isNaN(n) || n < 1) return null;
return n;
} Type guard
const isValidDailyLimit = (v) => v === null || (typeof v === 'number' && !isNaN(v) && v >= 1);
Prevention
- Use null (not 0) to mean 'no limit'.
- Coerce empty strings and 0 to null before validation.
When it happens
Trigger: Creating/updating a user with dailyMessageLimit set to 0, a negative number, a non-numeric string (e.g. 'unlimited', 'abc'), or the string 'null'.
Common situations: Frontend sends 0 intending 'disabled' instead of null. API client sends an empty string that Number() coerces to 0 or NaN. Import script misreads a blank column as 0.
Related errors
- Username cannot be longer than 64 characters
- Username must be at least 2 characters
- Username must start with a lowercase letter and only contain
- Invalid role. Allowed roles are: ${VALID_ROLES.join(", ")}
- Bio cannot be longer than 1,000 characters
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e30a468bcd7d7798.
Report an issue: GitHub.