{"record":{"id":"d0d31cc3e26ccead","repo":"mem0ai/mem0","slug":"bad-request-to-path-detail","errorCode":null,"errorMessage":"Bad request to ${path}: ${detail}","messagePattern":"Bad request to (.+?): (.+?)","errorType":"http","errorClass":"APIError","httpStatus":400,"severity":"error","filePath":"cli/node/src/backend/platform.ts","lineNumber":83,"sourceCode":"\t\tconst resp = await fetch(url, fetchOpts);\n\n\t\tif (resp.status === 401) {\n\t\t\tthrow new AuthError();\n\t\t}\n\t\tif (resp.status === 404) {\n\t\t\tthrow new NotFoundError(path);\n\t\t}\n\t\tif (resp.status === 400) {\n\t\t\tlet detail: string;\n\t\t\ttry {\n\t\t\t\tconst body = (await resp.json()) as Record<string, unknown>;\n\t\t\t\tdetail =\n\t\t\t\t\t((body.detail ?? body.message ?? JSON.stringify(body)) as string) ??\n\t\t\t\t\tresp.statusText;\n\t\t\t} catch {\n\t\t\t\tdetail = resp.statusText;\n\t\t\t}\n\t\t\tthrow new APIError(path, detail);\n\t\t}\n\t\tif (!resp.ok) {\n\t\t\tlet detail: string = resp.statusText;\n\t\t\ttry {\n\t\t\t\tconst body = (await resp.json()) as Record<string, unknown>;\n\t\t\t\tdetail = (body.detail ?? body.message ?? resp.statusText) as string;\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t\tthrow new Error(`HTTP ${resp.status}: ${detail}`);\n\t\t}\n\t\tif (resp.status === 204) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst data = await resp.json();\n\n\t\t// Pull the unclaimed-Agent-Mode notice out of the body (or the header","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/cli/node/src/backend/platform.ts#L65-L101","documentation":"require_auth is the stricter variant of verify_auth: it must produce a non-None User. When authentication used ADMIN_API_KEY or AUTH_DISABLED (paths that return None), it falls back to the first user in the users table; if that table is empty, no default user exists and the request fails with 401 'Authentication required.'","triggerScenarios":"Calling an endpoint guarded by require_auth with ADMIN_API_KEY or AUTH_DISABLED=true while the users table is completely empty (nobody has completed /setup). Also hit after a database wipe that removed users but kept the env configuration.","commonSituations":"Developer sets AUTH_DISABLED=true expecting open access, but endpoints requiring a real User still 401 because no admin was ever registered; fresh Docker deployment with ADMIN_API_KEY set but /setup never visited; database volume recreated empty while old env vars persisted.","solutions":["Register the first admin account at http://<host>:3000/setup (POST /auth/register) so the users table is non-empty.","Prefer a real Bearer/API-key login over ADMIN_API_KEY/AUTH_DISABLED for endpoints that need a User identity.","If the database was wiped, re-run onboarding to recreate the default user."],"exampleFix":"# before\n# AUTH_DISABLED=true in .env, users table empty\ncurl http://localhost:3000/api-keys  # -> 401 Authentication required.\n\n# after\ncurl -X POST http://localhost:3000/auth/register -H 'Content-Type: application/json' \\\n  -d '{\"name\":\"admin\",\"email\":\"admin@example.com\",\"password\":\"longpassword\"}'\n# then use the returned JWT","handlingStrategy":"validation","validationCode":"status = requests.get(f\"{BASE}/auth/setup-status\").json()\nif status[\"needsSetup\"]:\n    raise RuntimeError(\"Users table empty: complete /setup before using admin-key/disabled-auth endpoints\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make onboarding (register first admin) step 1 of every deployment runbook.","Health checks for the server should assert setup is complete, not just that the port answers.","After any DB wipe, immediately re-run setup before switching traffic."],"tags":["auth","http-401","bootstrap","rest-server"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}