{"record":{"id":"458cc79b4374715a","repo":"Mintplex-Labs/anything-llm","slug":"res-statustext-error-generating-api-key","errorCode":null,"errorMessage":"res.statusText || \"Error generating api key.\"","messagePattern":"res\\.statusText \\|\\| \"Error generating api key\\.\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/models/admin.js","lineNumber":216,"sourceCode":"        if (!res.ok) {\n          throw new Error(res.statusText || \"Error fetching api keys.\");\n        }\n        return res.json();\n      })\n      .catch((e) => {\n        console.error(e);\n        return { apiKeys: [], error: e.message };\n      });\n  },\n  generateApiKey: async function (data = {}) {\n    return fetch(`${API_BASE}/admin/generate-api-key`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify(data),\n    })\n      .then((res) => {\n        if (!res.ok) {\n          throw new Error(res.statusText || \"Error generating api key.\");\n        }\n        return res.json();\n      })\n      .catch((e) => {\n        console.error(e);\n        return { apiKey: null, error: e.message };\n      });\n  },\n  deleteApiKey: async function (apiKeyId = \"\") {\n    return fetch(`${API_BASE}/admin/delete-api-key/${apiKeyId}`, {\n      method: \"DELETE\",\n      headers: baseHeaders(),\n    })\n      .then((res) => res.ok)\n      .catch((e) => {\n        console.error(e);\n        return false;\n      });","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/frontend/src/models/admin.js#L198-L234","documentation":"The Qdrant 'namespace-stats' developer-API handler destructures { namespace = null } from the request body and throws immediately when falsy — request validation only, no Qdrant traffic. In this codebase namespaces map to Qdrant collections named after workspace slugs, so the caller must send the slug of an embedded workspace.","triggerScenarios":"POSTing to /api/ext/vectors/namespace-stats without a namespace field, with null/''/undefined, with a wrong key ('workspace', 'collection'), or with a body that never parsed because Content-Type wasn't application/json.","commonSituations":"Hand-written curl missing --data; API client built from the wrong docs version; automation assuming a default workspace; JSON key typo after copy-paste from another endpoint.","solutions":["Send { \"namespace\": \"<workspace-slug>\" } as JSON with Content-Type: application/json.","List valid slugs via the namespaces developer endpoint (or check the Qdrant console's collections list) before querying stats.","Match the slug exactly — lowercase, dashes for spaces.","If wrapping the API in code, validate the body locally first and fail with a clearer message."],"exampleFix":"# before\ncurl -X POST http://localhost:3001/api/ext/vectors/namespace-stats \\\n  -H \"Authorization: Bearer $API_KEY\"\n\n# after\ncurl -X POST http://localhost:3001/api/ext/vectors/namespace-stats \\\n  -H \"Authorization: Bearer $API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"namespace\": \"my-workspace\"}'","handlingStrategy":"validation","validationCode":"function isValidNamespaceStatsBody(body) {\n  return body != null && typeof body === 'object' &&\n    typeof body.namespace === 'string' && body.namespace.trim().length > 0;\n}\n\nif (!isValidNamespaceStatsBody(req.body)) {\n  return res.status(400).json({ error: 'namespace (workspace slug) is required' });\n}\nawait client.post('/api/ext/vectors/namespace-stats', req.body);","typeGuard":"function isNamespaceRequest(body) {\n  return (\n    typeof body === 'object' && body !== null &&\n    typeof body.namespace === 'string' &&\n    body.namespace.length > 0\n  );\n}","tryCatchPattern":"try {\n  const stats = await client.post('/api/ext/vectors/namespace-stats', { namespace });\n} catch (e) {\n  if (/namespace required/.test(e.message)) {\n    // caller bug: empty body or wrong key — fix the request, do not retry\n    throw new Error('Send { \"namespace\": \"<workspace-slug>\" } as JSON with Content-Type: application/json');\n  }\n  throw e;\n}","preventionTips":["Always send a JSON body with Content-Type: application/json on developer-API POSTs.","Derive the namespace from the workspace settings/list endpoint instead of hand-typing slugs.","Use a typed API client so missing required fields fail before the request leaves.","Reuse the documented key names exactly ('namespace')."],"tags":["qdrant","api-contract","request-validation","namespace","developer-api"],"backgroundTag":"missing-required-argument","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}