{"record":{"id":"b6618189874eb220","repo":"Mintplex-Labs/anything-llm","slug":"response-error-res-statustext","errorCode":null,"errorMessage":"${response?.error ?? res.statusText}","messagePattern":"\\$\\{response\\?\\.error \\?\\? res\\.statusText\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/models/communityHub.js","lineNumber":61,"sourceCode":"          error: e.message,\n        };\n      });\n  },\n\n  /**\n   * Import a bundle item from the community hub.\n   * @param {string} importId - The import ID of the item.\n   * @returns {Promise<{error: string | null, item: object | null}>}\n   */\n  importBundleItem: async (importId) => {\n    return await fetch(`${API_BASE}/community-hub/import`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify({ importId }),\n    })\n      .then(async (res) => {\n        const response = await res.json();\n        if (!res.ok) throw new Error(response?.error ?? res.statusText);\n        return response;\n      })\n      .catch((e) => {\n        return {\n          error: e.message,\n          item: null,\n        };\n      });\n  },\n\n  /**\n   * Update the hub settings (API key, etc.)\n   * @param {Object} data - The data to update.\n   * @returns {Promise<{success: boolean, error: string | null}>}\n   */\n  updateSettings: async (data) => {\n    return await fetch(`${API_BASE}/community-hub/settings`, {\n      method: \"POST\",","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/communityHub.js#L43-L79","documentation":"Thrown from `importBundleItem` on a non-ok `POST /api/community-hub/import`. Unlike the agentFlows models, this one correctly awaits `res.json()` first, then reads `response?.error ?? res.statusText`, so the server-provided message survives. The `.catch` returns `{ error, item: null }`.","triggerScenarios":"Invalid or expired `importId`; community-hub connection key not set/invalid; the bundle item no longer exists on the hub; rate limit; backend can't reach the hub upstream (502/504); 401 session expired.","commonSituations":"User pastes an old importId; hub API key missing or revoked; hub service is down; network egress from backend blocked.","solutions":["Read the returned `error` string — it usually states the precise hub-side problem.","Verify a valid community-hub connection key is configured (see getSettings/updateSettings).","Retry on 502/504/429 with backoff; treat 404/expired-importId as terminal.","Confirm backend egress to the hub domain is allowed.","On 401, re-authenticate the admin session."],"exampleFix":"// before — acceptable, but no retry for transient hub errors\nconst { error, item } = await CommunityHub.importBundleItem(importId);\nif (error) throw new Error(error);\n\n// after — retry transient upstream failures\nlet lastErr;\nfor (let attempt = 0; attempt < 3; attempt++) {\n  const { error, item } = await CommunityHub.importBundleItem(importId);\n  if (item) return item;\n  lastErr = error;\n  if (!/502|503|504|429|timeout/i.test(error)) break;\n  await new Promise(r => setTimeout(r, 500 * 2 ** attempt));\n}\nthrow new Error(lastErr || 'Failed to import bundle item');","handlingStrategy":"retry","validationCode":"function assertImportId(importId) {\n  if (typeof importId !== 'string' || !importId.trim()) {\n    throw new Error('A valid community-hub import id is required');\n  }\n}","typeGuard":"function isTransientHubError(msg) {\n  return /502|503|504|429|timeout|ECONN/i.test(String(msg || ''));\n}","tryCatchPattern":"const { error, item } = await CommunityHub.importBundleItem(importId);\nif (error) {\n  if (isTransientHubError(error)) { /* retry with backoff, then surface */ }\n  showToast(error);\n}","preventionTips":["Verify a valid community-hub connection key is configured before importing.","Retry only transient (502/503/504/429) errors; treat expired/404 importIds as terminal.","Confirm backend egress to the hub domain is allowed."],"tags":["frontend","community-hub","network","import","fetch"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}