Mintplex-Labs/anything-llm · error · Error
Failed to fetch ${url}: ${response.status}
Error message
Failed to fetch ${url}: ${response.status} What it means
DrupalWiki._doFetch throws on any non-ok response. It is used by page-index listing, single-page fetch, and attachment listing. Unlike Confluence there is no outer try/catch here — the error propagates directly to the caller.
Source
Thrown at collector/utils/extensions/DrupalWiki/DrupalWiki/index.js:240
#generateChunkSource(pageId, encryptionWorker) {
const payload = {
baseUrl: this.baseUrl,
pageId: pageId,
accessToken: this.accessToken,
};
return `drupalwiki://${
this.baseUrl
}/node/${pageId}?payload=${encryptionWorker.encrypt(
JSON.stringify(payload)
)}`;
}
async _doFetch(url) {
const response = await fetch(url, {
headers: this.#getHeaders(),
});
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status}`);
}
return response.json();
}
#getHeaders() {
return {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${this.accessToken}`,
};
}
#prepareStoragePath(baseUrl) {
const { hostname } = new URL(baseUrl);
const subFolder = slugify(`drupalwiki-${hostname}`).toLowerCase();
const outFolder = path.resolve(documentsFolder, subFolder);
if (!fs.existsSync(outFolder)) fs.mkdirSync(outFolder, { recursive: true });
return outFolder;View on GitHub (pinned to 526360e320)
Solutions
- Verify accessToken and baseUrl with a GET to /api/rest/scope/api/page?size=1&space=<id>.
- Confirm the spaceId exists for that instance.
- Check the status code embedded in the message.
- Ensure the DrupalWiki Scope API plugin is installed and the path matches.
Example fix
// before
if (!response.ok) throw new Error(`Failed to fetch ${url}: ${response.status}`);
// after — surface status text + handle 401 distinctly
if (!response.ok) {
if (response.status === 401) throw new Error(`DrupalWiki auth failed for ${url}`);
throw new Error(`DrupalWiki ${response.status} ${response.statusText} for ${url}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
async function drupalAuthOk(baseUrl, token) {
const r = await fetch(`${baseUrl}/api/rest/scope/api/page?size=1`, {
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
});
return r.ok;
} Try / catch
try { await wiki.loadAndStoreAllPagesForSpace(spaceId, enc); }
catch (e) {
if (/Failed to fetch .*: 401/.test(e.message)) { /* refresh token */ }
throw e;
} Prevention
- Validate the token/space before bulk import.
- Keep baseUrl consistent with the instance.
- Pin to a supported DrupalWiki/Scope API version.
When it happens
Trigger: DrupalWiki REST API returns non-2xx: 401 (bad accessToken), 403, 404 (wrong spaceId/pageId), 5xx, or a changed API path.
Common situations: Wrong/expired access token; baseUrl mismatch; spaceId does not exist; the Scope/DrupalWiki API plugin path changed between versions.
Related errors
- Failed to fetch ${url} from Confluence: ${response.status}
- Failed to fetch documents from Paperless-ngx: ${res.status}
- Failed to fetch documents from Paperless-ngx: ${error.messag
- Failed to fetch document content: ${response.status}
- Failed to sync Confluence page content. ${reason}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/f4a63f8c69b0c930.
Report an issue: GitHub.