{"record":{"id":"fd8eff1557e930a2","repo":"Mintplex-Labs/anything-llm","slug":"chromacloud-metadata-length-too-large-default-ma","errorCode":null,"errorMessage":"ChromaCloud::Metadata length too large (default max is ${this.limits.maxMetadataBytes}). Got ${JSON.stringify(testSubmission.metadata).length}. Upsert may fail!","messagePattern":"ChromaCloud::Metadata length too large \\(default max is (.+?)\\)\\. Got (.+?)\\. Upsert may fail!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/utils/vectorDbProviders/chromacloud/index.js","lineNumber":78,"sourceCode":"      id: submission.ids[0],\n      embedding: submission.embeddings[0],\n      metadata: submission.metadatas[0],\n      document: submission.documents[0],\n    };\n\n    if (testSubmission.embedding.length > this.limits.maxEmbeddingDim)\n      console.warn(\n        `ChromaCloud::Embedding dimension too large (default max is ${this.limits.maxEmbeddingDim}). Got ${testSubmission.embedding.length}. Upsert may fail!`\n      );\n    if (testSubmission.document.length > this.limits.maxDocumentBytes)\n      console.warn(\n        `ChromaCloud::Document length too large (default max is ${this.limits.maxDocumentBytes}). Got ${testSubmission.document.length}. Upsert may fail!`\n      );\n    if (\n      JSON.stringify(testSubmission.metadata).length >\n      this.limits.maxMetadataBytes\n    )\n      console.warn(\n        `ChromaCloud::Metadata length too large (default max is ${this.limits.maxMetadataBytes}). Got ${JSON.stringify(testSubmission.metadata).length}. Upsert may fail!`\n      );\n\n    // If the submissions are not too large, just add them directly.\n    if (submission.ids.length <= this.limits.maxRecordsPerWrite) {\n      await collection.add(submission);\n      return true;\n    }\n\n    this.logger(\n      `Upsert Payload is too large (max is ${this.limits.maxRecordsPerWrite} records). Splitting into chunks of ${this.limits.maxRecordsPerWrite} records.`\n    );\n    const chunks = [];\n    let chunkedSubmission = {\n      ids: [],\n      embeddings: [],\n      metadatas: [],\n      documents: [],","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/vectorDbProviders/chromacloud/index.js#L60-L96","documentation":"ChromaCloud.smartAdd() also enforces the maxMetadataBytes quota (4096): it JSON.stringify()s the first record's metadata object and warns when the serialized JSON exceeds that length, meaning the cloud upsert will likely be rejected with 422. Only submission.metadatas[0] is sampled per batch, and the limit counts the whole serialized object (keys, quotes, braces included), not a single field.","triggerScenarios":"Uploading documents whose per-record metadata contains very long strings — full scraped URLs with long query strings, entire descriptions or page excerpts, base64 blobs, tag dumps — or dozens of keys, pushing JSON.stringify(metadata).length past 4096 on the sampled first record.","commonSituations":"Custom metadata injected at upload time via the API, web-scrape data sources carrying long canonical URLs/titles, workspaces migrated from local Chroma (no metadata limit), and metadata that grew incrementally as more fields (tag, topic, source) were appended per document.","solutions":["Trim metadata before upload: keep string fields short (truncate URLs/titles to a few hundred chars) and drop non-essential keys so the total JSON stays under 4 KB.","Move bulky content (excerpts, long descriptions) into the document text or a separate store — metadata should hold small filterable scalars.","Re-embed the affected documents after cleaning metadata; previously rejected records are not retried automatically.","If the metadata genuinely must be large, self-host Chroma (VECTOR_DB=chroma) or pick a provider without a metadata byte quota."],"exampleFix":"// before: full URL + description pushed into metadata\nawait collection.add({\n  ids: [docId],\n  documents: [text],\n  metadatas: [{ url: longCanonicalUrl, description: fullPageDescription, ...rest }], // JSON > 4096 chars\n});\n\n// after: clamp metadata before upsert\nconst clampMetadata = (meta, maxJson = 4096) => {\n  const out = {};\n  for (const [k, v] of Object.entries(meta))\n    out[k] = typeof v === \"string\" && v.length > 256 ? v.slice(0, 256) : v;\n  if (JSON.stringify(out).length > maxJson)\n    throw new Error(`metadata still too large after clamping`);\n  return out;\n};\nawait collection.add({ ids: [docId], documents: [text], metadatas: [clampMetadata(meta)] });","handlingStrategy":"validation","validationCode":"const CHROMA_CLOUD_MAX_METADATA_JSON = 4096;\n\nfunction clampMetadata(metadata) {\n  const out = {};\n  for (const [key, value] of Object.entries(metadata)) {\n    out[key] =\n      typeof value === \"string\" && value.length > 256\n        ? value.slice(0, 256)\n        : value;\n  }\n  if (JSON.stringify(out).length > CHROMA_CLOUD_MAX_METADATA_JSON) {\n    throw new Error(\"Metadata exceeds Chroma Cloud 4 KB quota even after clamping — move data into document text.\");\n  }\n  return out;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat vector-store metadata as short filterable scalars only (title, source, type, dates) — never page content, base64, or full URLs with query strings.","Truncate long string fields at ingestion time; the limit counts the whole JSON.stringify output, including keys and punctuation.","When migrating from a local vector DB to a cloud one, run a metadata size audit over existing records before the first sync."],"tags":["chroma-cloud","metadata","vector-db","quotas","payload-size"],"backgroundTag":"payload-too-large","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}