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

  1. Read the returned `error` string — it usually states the precise hub-side problem.
  2. Verify a valid community-hub connection key is configured (see getSettings/updateSettings).
  3. Retry on 502/504/429 with backoff; treat 404/expired-importId as terminal.
  4. Confirm backend egress to the hub domain is allowed.
  5. 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

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


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