{"record":{"id":"cdbab49ecaf3b9e2","repo":"HeyPuter/puter","slug":"bad-request-cdbab4","errorCode":"bad_request","errorMessage":"`message` is required","messagePattern":"`message` is required","errorType":"http","errorClass":"HttpError","httpStatus":400,"severity":"error","filePath":"src/backend/controllers/system/SystemController.js","lineNumber":193,"sourceCode":"        // -- Contact us ----------------------------------------------\n\n        router.post(\n            '/contactUs',\n            {\n                subdomain: 'api',\n                requireUserActor: true,\n                allowFullAccessToken: true,\n                rateLimit: {\n                    scope: 'contact-us',\n                    limit: 10,\n                    window: 15 * 60_000,\n                    key: 'user',\n                },\n            },\n            async (req, res) => {\n                const { message } = req.body ?? {};\n                if (!message || typeof message !== 'string') {\n                    throw new HttpError(400, '`message` is required', {\n                        legacyCode: 'bad_request',\n                    });\n                }\n                if (message.length > 100_000) {\n                    throw new HttpError(\n                        400,\n                        '`message` is too long (max 100,000 characters)',\n                        { legacyCode: 'bad_request' },\n                    );\n                }\n\n                // Persist to feedback table for durability\n                try {\n                    await this.clients.db.write(\n                        'INSERT INTO `feedback` (`user_id`, `message`) VALUES (?, ?)',\n                        [req.actor.user.id, message],\n                    );\n                } catch (e) {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/controllers/system/SystemController.js#L175-L211","documentation":"Returned (HTTP 400, legacy code bad_request) by POST /contactUs on the api subdomain (SystemController). The route requires req.body.message to be a non-empty string. It is gated behind requireUserActor + allowFullAccessToken and a 10-per-15-minutes per-user rate limit.","triggerScenarios":"POSTing to /contactUs with no body, an empty message, a non-string message (number/object), or a Content-Type that fails to parse JSON so req.body is undefined.","commonSituations":"Missing or wrong Content-Type header (so body is undefined); form submission sending message in a different field; client sending {text} instead of {message}.","solutions":["Send { message: '...' } as JSON with Content-Type: application/json.","Ensure message is a non-empty string.","Verify req.body is parsed (check Content-Type and that the body is not double-stringified).","Confirm you are authenticated with a user actor or full-access token."],"exampleFix":"// before\nawait fetch('/contactUs', { method:'POST', body: JSON.stringify({ text }) });\n// after\nawait fetch('/contactUs', {\n  method:'POST',\n  headers:{'Content-Type':'application/json'},\n  body: JSON.stringify({ message: text }),\n});","handlingStrategy":"validation","validationCode":"function buildContactBody(message) {\n  if (typeof message !== 'string' || message.length === 0)\n    throw new TypeError('message is required and must be a non-empty string');\n  return { message };\n}","typeGuard":"const isValidContactMessage = (m) => typeof m === 'string' && m.length > 0;","tryCatchPattern":"try { await post('/contactUs', { message }); }\ncatch (e) { if (e?.code === 'bad_request' && /message is required/.test(e.message)) alert('Please enter a message'); else throw e; }","preventionTips":["Always send Content-Type: application/json.","Use the field name 'message'.","Disable the submit button when the field is empty."],"tags":["api","contact","validation","bad-request","user-actor"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}