{"record":{"id":"5981a0055b3edf31","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-fetch-documents-from-paperless-ngx-er","errorCode":null,"errorMessage":"Failed to fetch documents from Paperless-ngx: ${error.message}","messagePattern":"Failed to fetch documents from Paperless-ngx: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":200,"severity":"error","filePath":"collector/utils/extensions/PaperlessNgx/PaperlessNgxLoader/index.js","lineNumber":82,"sourceCode":"        }\n      }\n\n      console.log(\n        `Fetched ${documents.length} documents from Paperless-ngx (Pages: ${\n          page - 1\n        })`\n      );\n\n      const documentsWithContent = await Promise.all(\n        documents.map(async (doc) => {\n          const content = await this.fetchDocumentContent(doc.id);\n          return { ...doc, content };\n        })\n      );\n\n      return documentsWithContent.filter((doc) => !!doc.content);\n    } catch (error) {\n      throw new Error(\n        `Failed to fetch documents from Paperless-ngx: ${error.message}`\n      );\n    }\n  }\n\n  /**\n   * Fetches the content of a document from Paperless-ngx\n   * @param {string} documentId - The ID of the document to fetch\n   * @returns {Promise<string>} The content of the document\n   */\n  async fetchDocumentContent(documentId) {\n    try {\n      const response = await fetch(\n        `${this.baseUrl}/api/documents/${documentId}/download/`,\n        {\n          headers: this.baseHeaders,\n        }\n      );","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/a145d4d87d086bdb31d50f9bf9cd9c46d311780c/collector/utils/extensions/PaperlessNgx/PaperlessNgxLoader/index.js#L64-L100","documentation":"The novel-document twin of the cached-path failure: after embedding fresh chunks, the code calls getOrCreateCollection and throws when the result is falsy. Since a genuine 404 from getCollection would reject the promise, a falsy resolve means Qdrant answered with an empty or unexpected payload — collection creation failed server-side (classic cause: not enough free RAM to build a collection) or a client/server version mismatch changed the response shape.","triggerScenarios":"First document embedded into a brand-new workspace collection while Qdrant is memory-constrained; @qdrant/js-client-rest version returning a response the code reads as falsy; race between two concurrent addDocumentToNamespace calls both creating/deleting the same collection; collection creation rejected by a proxy or cloud quota.","commonSituations":"Qdrant in a small Docker container (default limits) on a busy host; first-ever embed on a fresh deployment failing while later ones succeed; mixing client 1.x with server 1.y across a breaking REST change; Qdrant Cloud free-tier quota exhausted.","solutions":["Check collection existence directly: curl $QDRANT_ENDPOINT/collections/<namespace> and read the Qdrant logs for the creation attempt.","Free or allocate more memory to the Qdrant container (collection creation is memory-hungry), then retry the embed.","Verify the @qdrant/js-client-rest version is compatible with your Qdrant server series; pin/upgrade so response shapes align.","If a quota (cloud tier / collection count limit) was hit, raise it or clean unused collections, then re-embed."],"exampleFix":"# before - first embed of a workspace throws 'Failed to create new QDrant collection!'\n\n# after - confirm and pre-create the collection with the engine's dimension\ncurl -X PUT $QDRANT_ENDPOINT/collections/my-workspace \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"vectors\":{\"size\":1536,\"distance\":\"Cosine\"}}'\n# getOrCreateCollection then takes the exists-branch and skips creation\n# also raise qdrant memory limits if creation failed with OOM:\n# docker run -m 4g ... qdrant/qdrant","handlingStrategy":"try-catch","validationCode":"// pre-create the collection with the engine's dimension before first embed\nconst dim = vectors[0]?.vector?.length;\nif (!dim) throw new Error('No vectors to infer dimension from');\nconst exists = await client.getCollection(namespace).then(() => true).catch(() => false);\nif (!exists) {\n  await client.createCollection(namespace, { vectors: { size: dim, distance: 'Cosine' } });\n}","typeGuard":"async function collectionReady(client, namespace) {\n  const c = await client.getCollection(namespace).catch(() => null);\n  return c != null && typeof c === 'object';\n}","tryCatchPattern":"try {\n  await vectorDB.addDocumentToNamespace(namespace, payload);\n} catch (e) {\n  if (/Failed to create new QDrant collection/.test(e.message)) {\n    // inspect and fix root cause, then retry this single document\n    const info = await client.getCollection(namespace).catch(() => null);\n    if (!info) {\n      await client.createCollection(namespace, { vectors: { size: vectors[0].vector.length, distance: 'Cosine' } });\n    }\n    return retryEmbed(doc);\n  }\n  throw e;\n}","preventionTips":["Provision collections with a known vector size during workspace/workspace-embedding setup.","Size Qdrant memory for collection creation (several GB free), especially in containers.","Pin compatible client/server versions and re-test after upgrading either side.","Retry first-embed once after fixing the cause — lazy creation failures are usually transient."],"tags":["qdrant","collection-creation","memory-limits","first-embed","version-compatibility"],"backgroundTag":"collection-creation-failed","analyzedSha":"a145d4d87d086bdb31d50f9bf9cd9c46d311780c","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}