{"record":{"id":"2760e198f07d91e4","repo":"Mintplex-Labs/anything-llm","slug":"import-id-is-required","errorCode":null,"errorMessage":"Import ID is required","messagePattern":"Import ID is required","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/utils/middleware/communityHubDownloadsEnabled.js","lineNumber":53,"sourceCode":"    item.visibility !== \"private\" &&\n    process.env.COMMUNITY_HUB_BUNDLE_DOWNLOADS_ENABLED !== \"allow_all\"\n  ) {\n    return response.status(422).json({\n      error:\n        \"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\",\n    });\n  }\n  next();\n}\n\n/**\n * Fetch the bundle item from the community hub.\n * Sets `response.locals.bundleItem` and `response.locals.bundleUrl`.\n */\nasync function communityHubItem(request, response, next) {\n  const { importId } = reqBody(request);\n  if (!importId)\n    return response.status(500).json({\n      success: false,\n      error: \"Import ID is required\",\n    });\n\n  const {\n    url,\n    item,\n    error: fetchError,\n  } = await CommunityHub.getBundleItem(importId);\n  if (fetchError)\n    return response.status(500).json({\n      success: false,\n      error: fetchError,\n    });\n\n  response.locals.bundleItem = item;\n  response.locals.bundleUrl = url;\n  next();","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/middleware/communityHubDownloadsEnabled.js#L35-L71","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send a JSON body { \"importId\": \"<id>\" } with Content-Type: application/json","Use the exact camelCase field name importId (not import_id / importID)","Copy the importId verbatim from the hub item page — no surrounding spaces or quotes"],"exampleFix":"// before\nawait fetch('/api/community-hub/import', {\n  method: 'POST',\n  headers: { 'Content-Type': 'text/plain' },\n  body: JSON.stringify({ import_id: id }),\n});\n\n// after\nawait fetch('/api/community-hub/import', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ importId: id }),\n});","handlingStrategy":"validation","validationCode":"if (typeof importId !== 'string' || importId.trim() === '')\n  throw new Error('importId required');\nawait fetch(url, {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ importId: importId.trim() }),\n});","typeGuard":"const isValidImportRequest = (body) =>\n  typeof body?.importId === 'string' && body.importId.length > 0;","tryCatchPattern":null,"preventionTips":["Always set Content-Type: application/json on these POSTs","Use the exact camelCase key importId","Validate the body shape in one shared request-builder"],"tags":["request-validation","community-hub","express","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}