{"record":{"id":"e2d6fc041e580cfe","repo":"Mintplex-Labs/anything-llm","slug":"invalid-device-os-deviceos","errorCode":null,"errorMessage":"Invalid device OS - ${deviceOs}","messagePattern":"Invalid device OS - (.+?)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/mobile/index.js","lineNumber":134,"sourceCode":"   * Will create a new device in the database but requires approval by the user\n   * before it can be used.\n   * @param {import(\"express\").Request} request\n   * @param {import(\"express\").Response} response\n   */\n  app.post(\n    \"/mobile/register\",\n    [validRegistrationToken],\n    async (request, response) => {\n      try {\n        const body = reqBody(request);\n        const result = await MobileDevice.create({\n          deviceOs: body.deviceOs,\n          deviceName: body.deviceName,\n          userId: response.locals?.user?.id,\n        });\n\n        if (result.error)\n          return response.status(400).json({ error: result.error });\n        return response.status(200).json({\n          token: result.device.token,\n          platform: MobileDevice.platform,\n        });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.post(\n    \"/mobile/send/:command\",\n    [validDeviceToken],\n    async (request, response) => {\n      try {\n        return handleMobileCommand(request, response);\n      } catch (e) {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/mobile/index.js#L116-L152","documentation":"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.","triggerScenarios":"POST /api/mobile/register with deviceOs 'ios', 'Android' (capital A fails the lowercase whitelist), 'web', or any other string.","commonSituations":"iOS app pointed at a backend that only whitelists android; client capitalizing the OS name; desktop client reusing the mobile register endpoint.","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"],"exampleFix":"// server/models/mobileDevice.js (fork only)\n// before\nvalidDeviceOs: ['android'],\n// after\nvalidDeviceOs: ['android', 'ios'],","handlingStrategy":"validation","validationCode":"const SUPPORTED_OS = ['android'];\nif (!SUPPORTED_OS.includes(deviceOs)) {\n  throw new Error(`Unsupported platform ${deviceOs} — cannot register`);\n}","typeGuard":"/** @param {string} os */\nfunction isSupportedDeviceOs(os) {\n  return ['android'].includes(os.toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["mobile","registration","enum","platform","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}