{"record":{"id":"d02c9b3afd9bc513","repo":"Mintplex-Labs/anything-llm","slug":"must-be-a-boolean","errorCode":null,"errorMessage":"Must be a boolean","messagePattern":"Must be a boolean","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/mobile/index.js","lineNumber":51,"sourceCode":"  );\n\n  /**\n   * Updates the device status via an updates object.\n   * @param {import(\"express\").Request} request\n   * @param {import(\"express\").Response} response\n   */\n  app.post(\n    \"/mobile/update/:id\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const body = reqBody(request);\n        const updates = await MobileDevice.update(\n          Number(request.params.id),\n          body\n        );\n        if (updates.error)\n          return response.status(400).json({ error: updates.error });\n        return response.status(200).json({ updates });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  /**\n   * Deletes a device from the database.\n   * @param {import(\"express\").Request} request\n   * @param {import(\"express\").Response} response\n   */\n  app.delete(\n    \"/mobile/:id\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/mobile/index.js#L33-L69","documentation":"POST /api/mobile/update/:id accepts exactly one writable field, approved, and server/models/mobileDevice.js validates it with typeof value !== 'boolean'. If the body's approved is a string ('true'), number (1), or null, update returns { error: 'Must be a boolean' } which the endpoint relays as HTTP 400. Only literal JSON booleans pass.","triggerScenarios":"Sending {\"approved\":\"true\"} (string), {\"approved\":1}, or a form-urlencoded body where Express parses the value as a string; sending approved:null to try to 'clear' the field.","commonSituations":"HTML forms or FormData serializing booleans as strings; clients whose types allow boolean|string; curl commands with the value quoted; query-string style bodies.","solutions":["Send a real JSON boolean with Content-Type: application/json: {\"approved\":true}","Convert form/DOM values explicitly before sending: approved: checkbox.checked","In curl, do not quote the boolean: -d '{\"approved\":true}' not '{\"approved\":\"true\"}'"],"exampleFix":"// before\nfetch('/api/mobile/update/3', {\n  method: 'POST',\n  body: JSON.stringify({ approved: 'true' }),\n});\n\n// after\nfetch('/api/mobile/update/3', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ approved: true }),\n});","handlingStrategy":"type-guard","validationCode":"const payload = { approved: typeof rawValue === 'string' ? rawValue === 'true' : Boolean(rawValue) };","typeGuard":"/** @param {unknown} v */\nfunction isBooleanUpdate(v) {\n  return v !== null && typeof v.approved === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["Type the update payload as { approved: boolean } in TS and never widen it","Always send Content-Type: application/json with JSON.stringify bodies","Convert DOM/form inputs with .checked or explicit comparison, not string passthrough"],"tags":["mobile","validation","boolean","request-body","type-coercion"],"backgroundTag":"schema-validation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}