{"record":{"id":"e30a468bcd7d7798","repo":"Mintplex-Labs/anything-llm","slug":"daily-message-limit-must-be-null-or-a-number-great","errorCode":null,"errorMessage":"Daily message limit must be null or a number greater than or equal to 1","messagePattern":"Daily message limit must be null or a number greater than or equal to 1","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/models/user.js","lineNumber":64,"sourceCode":"        return username;\n      } catch (e) {\n        throw new Error(e.message);\n      }\n    },\n    role: (role = \"default\") => {\n      const VALID_ROLES = [\"default\", \"admin\", \"manager\"];\n      if (!VALID_ROLES.includes(role)) {\n        throw new Error(\n          `Invalid role. Allowed roles are: ${VALID_ROLES.join(\", \")}`\n        );\n      }\n      return String(role);\n    },\n    dailyMessageLimit: (dailyMessageLimit = null) => {\n      if (dailyMessageLimit === null) return null;\n      const limit = Number(dailyMessageLimit);\n      if (isNaN(limit) || limit < 1) {\n        throw new Error(\n          \"Daily message limit must be null or a number greater than or equal to 1\"\n        );\n      }\n      return limit;\n    },\n    bio: (bio = \"\") => {\n      if (!bio || typeof bio !== \"string\") return \"\";\n      if (bio.length > 1000)\n        throw new Error(\"Bio cannot be longer than 1,000 characters\");\n      return String(bio);\n    },\n  },\n  // validations for the above writable fields.\n  castColumnValue: function (key, value) {\n    switch (key) {\n      case \"suspended\":\n        return Number(Boolean(value));\n      case \"dailyMessageLimit\":","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/models/user.js#L46-L82","documentation":"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.","triggerScenarios":"Creating/updating a user with dailyMessageLimit set to 0, a negative number, a non-numeric string (e.g. 'unlimited', 'abc'), or the string 'null'.","commonSituations":"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.","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."],"exampleFix":"// before\nUser.create({ username, password, dailyMessageLimit: 0 });\n// after\nUser.create({ username, password, dailyMessageLimit: null });","handlingStrategy":"validation","validationCode":"function normalizeDailyLimit(v) {\n  if (v === null || v === '' || v === undefined) return null;\n  const n = Number(v);\n  if (isNaN(n) || n < 1) return null;\n  return n;\n}","typeGuard":"const isValidDailyLimit = (v) => v === null || (typeof v === 'number' && !isNaN(v) && v >= 1);","tryCatchPattern":null,"preventionTips":["Use null (not 0) to mean 'no limit'.","Coerce empty strings and 0 to null before validation."],"tags":["validation","user","numeric","quota"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}