Mintplex-Labs/anything-llm · error
Invalid device OS - ${deviceOs}
Error message
Invalid device OS - ${deviceOs} What it means
MobileDevice.create rejects any deviceOs not in MobileDevice.validDeviceOs (currently ['android']) with `Invalid device OS - ${deviceOs}`, relayed as HTTP 400 by POST /api/mobile/register. The whitelist check happens before the value is lowercased for storage, so casing matters.
Source
Thrown at server/endpoints/mobile/index.js:134
* Will create a new device in the database but requires approval by the user
* before it can be used.
* @param {import("express").Request} request
* @param {import("express").Response} response
*/
app.post(
"/mobile/register",
[validRegistrationToken],
async (request, response) => {
try {
const body = reqBody(request);
const result = await MobileDevice.create({
deviceOs: body.deviceOs,
deviceName: body.deviceName,
userId: response.locals?.user?.id,
});
if (result.error)
return response.status(400).json({ error: result.error });
return response.status(200).json({
token: result.device.token,
platform: MobileDevice.platform,
});
} catch (e) {
console.error(e);
response.sendStatus(500).end();
}
}
);
app.post(
"/mobile/send/:command",
[validDeviceToken],
async (request, response) => {
try {
return handleMobileCommand(request, response);
} catch (e) {View on GitHub (pinned to 3aec848f28)
Solutions
- Send exactly 'android' (lowercase) as deviceOs
- In a fork that must support more platforms, extend the whitelist: validDeviceOs: ['android', 'ios']
- Guard client-side so unsupported platforms never call /mobile/register
Example fix
// server/models/mobileDevice.js (fork only) // before validDeviceOs: ['android'], // after validDeviceOs: ['android', 'ios'],
Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_OS = ['android'];
if (!SUPPORTED_OS.includes(deviceOs)) {
throw new Error(`Unsupported platform ${deviceOs} — cannot register`);
} Type guard
/** @param {string} os */
function isSupportedDeviceOs(os) {
return ['android'].includes(os.toLowerCase());
} Prevention
- Send lowercase 'android' exactly
- Gate the register flow on the platform check so unsupported builds never call it
- If forking the server, keep the client whitelist in sync with validDeviceOs
When it happens
Trigger: POST /api/mobile/register with deviceOs 'ios', 'Android' (capital A fails the lowercase whitelist), 'web', or any other string.
Common situations: iOS app pointed at a backend that only whitelists android; client capitalizing the OS name; desktop client reusing the mobile register endpoint.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Device OS and name are required
- Invalid scope: ${JSON.stringify(v)}
- Invalid role. Allowed roles are: ${VALID_ROLES.join(", ")}
- Must be a boolean
- Registration token is required
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/e2d6fc041e580cfe.
Report an issue: GitHub.