Mintplex-Labs/anything-llm · error
${response?.error ?? res.statusText}
Error message
${response?.error ?? res.statusText} What it means
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 }`.
Source
Thrown at frontend/src/models/communityHub.js:61
error: e.message,
};
});
},
/**
* Import a bundle item from the community hub.
* @param {string} importId - The import ID of the item.
* @returns {Promise<{error: string | null, item: object | null}>}
*/
importBundleItem: async (importId) => {
return await fetch(`${API_BASE}/community-hub/import`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify({ importId }),
})
.then(async (res) => {
const response = await res.json();
if (!res.ok) throw new Error(response?.error ?? res.statusText);
return response;
})
.catch((e) => {
return {
error: e.message,
item: null,
};
});
},
/**
* Update the hub settings (API key, etc.)
* @param {Object} data - The data to update.
* @returns {Promise<{success: boolean, error: string | null}>}
*/
updateSettings: async (data) => {
return await fetch(`${API_BASE}/community-hub/settings`, {
method: "POST",View on GitHub (pinned to 526360e320)
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.
Example fix
// before — acceptable, but no retry for transient hub errors
const { error, item } = await CommunityHub.importBundleItem(importId);
if (error) throw new Error(error);
// after — retry transient upstream failures
let lastErr;
for (let attempt = 0; attempt < 3; attempt++) {
const { error, item } = await CommunityHub.importBundleItem(importId);
if (item) return item;
lastErr = error;
if (!/502|503|504|429|timeout/i.test(error)) break;
await new Promise(r => setTimeout(r, 500 * 2 ** attempt));
}
throw new Error(lastErr || 'Failed to import bundle item'); Defensive patterns
Strategy: retry
Validate before calling
function assertImportId(importId) {
if (typeof importId !== 'string' || !importId.trim()) {
throw new Error('A valid community-hub import id is required');
}
} Type guard
function isTransientHubError(msg) {
return /502|503|504|429|timeout|ECONN/i.test(String(msg || ''));
} Try / catch
const { error, item } = await CommunityHub.importBundleItem(importId);
if (error) {
if (isTransientHubError(error)) { /* retry with backoff, then surface */ }
showToast(error);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: User pastes an old importId; hub API key missing or revoked; hub service is down; network egress from backend blocked.
Related errors
- ${response.error || "Failed to fetch settings"}
- ${res.statusText || "Error fetching api keys."}
- ${res.statusText || "Error generating api key."}
- ${res.error || "Failed to save flow"}
- ${res.error || "Failed to get flow"}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/b6618189874eb220.
Report an issue: GitHub.