Mintplex-Labs/anything-llm · error

Import ID is required

Error message

Import ID is required

What it means

Validation failure in the communityHubItem middleware: it reads reqBody(request).importId and requires a non-empty value before fetching the bundle. The response is HTTP 500 with 'Import ID is required' — a misleading status for what is a client error (the middleware family here uses 500 for its failures).

Source

Thrown at server/utils/middleware/communityHubDownloadsEnabled.js:53

    item.visibility !== "private" &&
    process.env.COMMUNITY_HUB_BUNDLE_DOWNLOADS_ENABLED !== "allow_all"
  ) {
    return response.status(422).json({
      error:
        "Community hub bundle downloads are limited to verified public items or private team items only. Please contact the system administrator to review or modify this setting. See https://docs.anythingllm.com/configuration#anythingllm-hub-agent-skills",
    });
  }
  next();
}

/**
 * Fetch the bundle item from the community hub.
 * Sets `response.locals.bundleItem` and `response.locals.bundleUrl`.
 */
async function communityHubItem(request, response, next) {
  const { importId } = reqBody(request);
  if (!importId)
    return response.status(500).json({
      success: false,
      error: "Import ID is required",
    });

  const {
    url,
    item,
    error: fetchError,
  } = await CommunityHub.getBundleItem(importId);
  if (fetchError)
    return response.status(500).json({
      success: false,
      error: fetchError,
    });

  response.locals.bundleItem = item;
  response.locals.bundleUrl = url;
  next();

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Send a JSON body { "importId": "<id>" } with Content-Type: application/json
  2. Use the exact camelCase field name importId (not import_id / importID)
  3. Copy the importId verbatim from the hub item page — no surrounding spaces or quotes

Example fix

// before
await fetch('/api/community-hub/import', {
  method: 'POST',
  headers: { 'Content-Type': 'text/plain' },
  body: JSON.stringify({ import_id: id }),
});

// after
await fetch('/api/community-hub/import', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ importId: id }),
});
Defensive patterns

Strategy: validation

Validate before calling

if (typeof importId !== 'string' || importId.trim() === '')
  throw new Error('importId required');
await fetch(url, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ importId: importId.trim() }),
});

Type guard

const isValidImportRequest = (body) =>
  typeof body?.importId === 'string' && body.importId.length > 0;

Prevention

When it happens

Trigger: POSTing to a hub import route with a JSON body that omits importId, sets it to empty string or null, or sends a body that fails to parse as JSON (wrong Content-Type) so reqBody yields nothing usable.

Common situations: Client sends { import_id: '...' } (underscore instead of camelCase); Content-Type set to text/plain so the JSON body is not parsed; copy-paste of the hub item URL instead of its importId string.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/2760e198f07d91e4. Report an issue: GitHub.