Mintplex-Labs/anything-llm · error · Error

Failed to fetch ${url} from Confluence: ${response.status}

Error message

Failed to fetch ${url} from Confluence: ${response.status}

What it means

ConfluencePagesLoader.fetchConfluenceData throws when the Confluence REST response is not ok. The surrounding catch re-throws error.message. This surfaces during fetchAllPagesInSpace pagination.

Source

Thrown at collector/utils/extensions/Confluence/ConfluenceLoader/index.js:75

      this.log("Error:", error);
      return [];
    }
  }

  async fetchConfluenceData(url) {
    try {
      const initialHeaders = {
        "Content-Type": "application/json",
        Accept: "application/json",
      };
      const authHeader = this.authorizationHeader;
      if (authHeader) initialHeaders.Authorization = authHeader;

      // If SSL bypass is enabled, set the NODE_TLS_REJECT_UNAUTHORIZED environment variable
      if (this.bypassSSL) process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
      const response = await fetch(url, { headers: initialHeaders });
      if (!response.ok) {
        throw new Error(
          `Failed to fetch ${url} from Confluence: ${response.status}`
        );
      }
      return await response.json();
    } catch (error) {
      this.log("Error:", error);
      throw new Error(error.message);
    } finally {
      if (this.bypassSSL) process.env.NODE_TLS_REJECT_UNAUTHORIZED = "1";
    }
  }

  // https://developer.atlassian.com/cloud/confluence/rest/v2/intro/#auth
  async fetchAllPagesInSpace(start = 0, limit = this.limit) {
    const url = `${this.baseUrl}${
      this.cloud ? "/wiki" : ""
    }/rest/api/content?spaceKey=${
      this.spaceKey

View on GitHub (pinned to 526360e320)

Solutions

  1. Verify baseUrl + spaceKey + credentials (username/accessToken or personalAccessToken).
  2. For Confluence Cloud ensure baseUrl is the cloud host and cloud=true (so /wiki is prepended).
  3. Set bypassSSL=true only for trusted self-hosted instances with SSL issues.
  4. Check the HTTP status embedded in the message to narrow the cause.

Example fix

// before
if (!response.ok) throw new Error(`Failed to fetch ${url} from Confluence: ${response.status}`);

// after — include status text + a body excerpt for diagnostics
if (!response.ok) {
  const body = await response.text();
  throw new Error(`Confluence ${response.status} ${response.statusText} for ${url}: ${body.slice(0, 200)}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

async function confluenceReachable(baseUrl, headers) {
  const r = await fetch(`${baseUrl}/rest/api/space`, { headers });
  return r.ok;
}

Try / catch

try { await loader.fetchAllPagesInSpace(); }
catch (e) {
  if (/Failed to fetch .* from Confluence: 401/.test(e.message)) { /* refresh token */ }
  if (/Failed to fetch .* from Confluence: 404/.test(e.message)) { /* check baseUrl/spaceKey */ }
  throw e;
}

Prevention

When it happens

Trigger: Confluence API returns non-2xx: 401 (bad token/credentials), 403 (no space access), 404 (wrong baseUrl/spaceKey), 429 (rate limit), 5xx. SSL handshake failures when bypassSSL is off.

Common situations: Expired personal access token; wrong spaceKey; on-prem baseUrl missing the cloud /wiki prefix; SSL issues on self-hosted; network blocking the Confluence host.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/727054b01e391a45. Report an issue: GitHub.