{"record":{"id":"e6410844870afa17","repo":"Mintplex-Labs/anything-llm","slug":"namespace-required","errorCode":null,"errorMessage":"namespace required","messagePattern":"namespace required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/utils/vectorDbProviders/chroma/index.js","lineNumber":418,"sourceCode":"\n    const sources = sourceDocuments.map((metadata, i) => ({\n      metadata: {\n        ...metadata,\n        text: contextTexts[i],\n        score: scores?.[i] || null,\n      },\n    }));\n\n    return {\n      contextTexts,\n      sources: this.curateSources(sources),\n      message: false,\n    };\n  }\n\n  async \"namespace-stats\"(reqBody = {}) {\n    const { namespace = null } = reqBody;\n    if (!namespace) throw new Error(\"namespace required\");\n    const { client } = await this.connect();\n    if (!(await this.namespaceExists(client, this.normalize(namespace))))\n      throw new Error(\"Namespace by that name does not exist.\");\n    const stats = await this.namespace(client, this.normalize(namespace));\n    return stats\n      ? stats\n      : { message: \"No stats were able to be fetched from DB for namespace\" };\n  }\n\n  async \"delete-namespace\"(reqBody = {}) {\n    const { namespace = null } = reqBody;\n    const { client } = await this.connect();\n    if (!(await this.namespaceExists(client, this.normalize(namespace))))\n      throw new Error(\"Namespace by that name does not exist.\");\n\n    const details = await this.namespace(client, this.normalize(namespace));\n    await this.deleteVectorsInNamespace(client, this.normalize(namespace));\n    return {","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/vectorDbProviders/chroma/index.js#L400-L436","documentation":"ChromaVectorDb's 'namespace-stats' command (invoked through the developer/tools endpoints that dispatch VectorDb['namespace-stats']) throws 'namespace required' when reqBody.namespace is null/absent. It is a request-shape guard: the dispatcher expects { namespace: '<workspace-slug>' }.","triggerScenarios":"Calling the dev endpoint or VectorDb['namespace-stats']({}) / ({ namespace: null }) - missing key, undefined slug, or a payload built from a workspace that failed to load.","commonSituations":"Manual curl/Postman against /dev endpoints with an incomplete JSON body; automation scripts iterating workspaces where one record lacks a slug; renamed payload field (name vs namespace).","solutions":["Send { \"namespace\": \"<workspace-slug>\" } in the request body.","Confirm the workspace slug via the UI (workspace URL) or the workspaces API before calling stats.","In scripts, filter out falsy slugs before invoking the command."],"exampleFix":"// before\nconst stats = await VectorDb['namespace-stats']({});\n\n// after\nconst stats = await VectorDb['namespace-stats']({ namespace: workspace.slug });","handlingStrategy":"validation","validationCode":"function normalizeNamespaceCommand(body) {\n  const ns = body?.namespace?.trim();\n  if (!ns) throw new Error(\"Request body must include a non-empty 'namespace' (workspace slug).\");\n  return { namespace: ns };\n}","typeGuard":"function hasNamespace(body) {\n  return typeof body?.namespace === 'string' && body.namespace.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Validate request bodies at the endpoint boundary before dispatching VectorDb commands.","Derive namespace from the workspace record (slug) rather than user input in admin tooling."],"tags":["chroma","vector-db","namespace","argument-validation","developer-tools"],"backgroundTag":"missing-required-argument","analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}