Mintplex-Labs/anything-llm · error · Error
Failed to fetch documents from Paperless-ngx: ${error.messag
Error message
Failed to fetch documents from Paperless-ngx: ${error.message} What it means
Outer catch in fetchAllDocuments — wraps any error that escaped the inner per-page handling (e.g. an error thrown while resolving document content via Promise.all, or a non-fetch programming error). The inner page errors are swallowed, so this usually originates from fetchDocumentContent or array processing.
Source
Thrown at collector/utils/extensions/PaperlessNgx/PaperlessNgxLoader/index.js:81
}
}
console.log(
`Fetched ${documents.length} documents from Paperless-ngx (Pages: ${
page - 1
})`
);
const documentsWithContent = await Promise.all(
documents.map(async (doc) => {
const content = await this.fetchDocumentContent(doc.id);
return { ...doc, content };
})
);
return documentsWithContent.filter((doc) => !!doc.content);
} catch (error) {
throw new Error(
`Failed to fetch documents from Paperless-ngx: ${error.message}`
);
}
}
/**
* Fetches the content of a document from Paperless-ngx
* @param {string} documentId - The ID of the document to fetch
* @returns {Promise<string>} The content of the document
*/
async fetchDocumentContent(documentId) {
try {
const response = await fetch(
`${this.baseUrl}/api/documents/${documentId}/download/`,
{
headers: this.baseHeaders,
}
);View on GitHub (pinned to 526360e320)
Solutions
- Inspect error.message — it is the wrapped inner cause.
- Note fetchDocumentContent normally swallows its own errors and returns "", so a propagated error is unusual.
- Validate the documents response shape (results array, next, etc.) before processing.
Example fix
// before
throw new Error(`Failed to fetch documents from Paperless-ngx: ${error.message}`);
// after — preserve the cause and original stack
const wrapped = new Error(`Failed to fetch documents from Paperless-ngx: ${error.message}`);
wrapped.cause = error;
throw wrapped; Defensive patterns
Strategy: try-catch
Try / catch
try { const docs = await loader.load(); }
catch (e) {
if (e.message.startsWith("Failed to fetch documents from Paperless-ngx:")) {
/* inspect inner cause — likely content fetch or response-shape error */
}
throw e;
} Prevention
- Validate the API response shape before processing.
- Keep fetchDocumentContent defensive (it already returns '').
- Preserve the inner cause when wrapping errors.
When it happens
Trigger: An exception propagates from the documents-with-content Promise.all or another uncaught path inside fetchAllDocuments; the inner per-page try/catch does not cover this stage.
Common situations: fetchDocumentContent throwing despite its own catch (unusual), an unexpected response shape (no results array), or a programming error in the map.
Related errors
- Failed to fetch documents from Paperless-ngx: ${res.status}
- Failed to fetch document content: ${response.status}
- Failed to fetch ${url} from Confluence: ${response.status}
- Failed to fetch ${url}: ${response.status}
- Failed to fetch document content
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/5981a0055b3edf31.
Report an issue: GitHub.