{"record":{"id":"727054b01e391a45","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-fetch-url-from-confluence-response","errorCode":null,"errorMessage":"Failed to fetch ${url} from Confluence: ${response.status}","messagePattern":"Failed to fetch (.+?) from Confluence: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"collector/utils/extensions/Confluence/ConfluenceLoader/index.js","lineNumber":75,"sourceCode":"      this.log(\"Error:\", error);\n      return [];\n    }\n  }\n\n  async fetchConfluenceData(url) {\n    try {\n      const initialHeaders = {\n        \"Content-Type\": \"application/json\",\n        Accept: \"application/json\",\n      };\n      const authHeader = this.authorizationHeader;\n      if (authHeader) initialHeaders.Authorization = authHeader;\n\n      // If SSL bypass is enabled, set the NODE_TLS_REJECT_UNAUTHORIZED environment variable\n      if (this.bypassSSL) process.env.NODE_TLS_REJECT_UNAUTHORIZED = \"0\";\n      const response = await fetch(url, { headers: initialHeaders });\n      if (!response.ok) {\n        throw new Error(\n          `Failed to fetch ${url} from Confluence: ${response.status}`\n        );\n      }\n      return await response.json();\n    } catch (error) {\n      this.log(\"Error:\", error);\n      throw new Error(error.message);\n    } finally {\n      if (this.bypassSSL) process.env.NODE_TLS_REJECT_UNAUTHORIZED = \"1\";\n    }\n  }\n\n  // https://developer.atlassian.com/cloud/confluence/rest/v2/intro/#auth\n  async fetchAllPagesInSpace(start = 0, limit = this.limit) {\n    const url = `${this.baseUrl}${\n      this.cloud ? \"/wiki\" : \"\"\n    }/rest/api/content?spaceKey=${\n      this.spaceKey","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/extensions/Confluence/ConfluenceLoader/index.js#L57-L93","documentation":"ConfluencePagesLoader.fetchConfluenceData throws when the Confluence REST response is not ok. The surrounding catch re-throws error.message. This surfaces during fetchAllPagesInSpace pagination.","triggerScenarios":"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.","commonSituations":"Expired personal access token; wrong spaceKey; on-prem baseUrl missing the cloud /wiki prefix; SSL issues on self-hosted; network blocking the Confluence host.","solutions":["Verify baseUrl + spaceKey + credentials (username/accessToken or personalAccessToken).","For Confluence Cloud ensure baseUrl is the cloud host and cloud=true (so /wiki is prepended).","Set bypassSSL=true only for trusted self-hosted instances with SSL issues.","Check the HTTP status embedded in the message to narrow the cause."],"exampleFix":"// before\nif (!response.ok) throw new Error(`Failed to fetch ${url} from Confluence: ${response.status}`);\n\n// after — include status text + a body excerpt for diagnostics\nif (!response.ok) {\n  const body = await response.text();\n  throw new Error(`Confluence ${response.status} ${response.statusText} for ${url}: ${body.slice(0, 200)}`);\n}","handlingStrategy":"try-catch","validationCode":"async function confluenceReachable(baseUrl, headers) {\n  const r = await fetch(`${baseUrl}/rest/api/space`, { headers });\n  return r.ok;\n}","typeGuard":null,"tryCatchPattern":"try { await loader.fetchAllPagesInSpace(); }\ncatch (e) {\n  if (/Failed to fetch .* from Confluence: 401/.test(e.message)) { /* refresh token */ }\n  if (/Failed to fetch .* from Confluence: 404/.test(e.message)) { /* check baseUrl/spaceKey */ }\n  throw e;\n}","preventionTips":["Validate credentials with a /rest/api/space call before bulk loading.","Keep tokens fresh; surface expiry.","Double-check cloud vs on-prem baseUrl shape.","Use bypassSSL only for trusted instances."],"tags":["confluence","http","integration","auth"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}