{"record":{"id":"40e8a7047949ef48","repo":"Mintplex-Labs/anything-llm","slug":"community-hub-connection-key-not-found","errorCode":null,"errorMessage":"Community Hub connection key not found","messagePattern":"Community Hub connection key not found","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/communityHub.js","lineNumber":193,"sourceCode":"        const { connectionKey } = await SystemSettings.hubSettings();\n        const items = await CommunityHub.fetchUserItems(connectionKey);\n        response.status(200).json({ success: true, ...items });\n      } catch (error) {\n        console.error(error);\n        response.status(500).json({ success: false, error: error.message });\n      }\n    }\n  );\n\n  app.post(\n    \"/community-hub/:communityHubItemType/create\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { communityHubItemType } = request.params;\n        const { connectionKey } = await SystemSettings.hubSettings();\n        if (!connectionKey)\n          throw new Error(\"Community Hub connection key not found\");\n\n        const data = reqBody(request);\n        const { success, error, itemId } = await CommunityHub.createStaticItem(\n          communityHubItemType,\n          data,\n          connectionKey\n        );\n        if (!success) throw new Error(error);\n\n        await EventLogs.logEvent(\n          \"community_hub_publish\",\n          { itemType: communityHubItemType },\n          response.locals?.user?.id\n        );\n        response\n          .status(200)\n          .json({ success: true, error: null, item: { id: itemId } });\n      } catch (error) {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/communityHub.js#L175-L211","documentation":"Thrown by POST /community-hub/:communityHubItemType/create (admin-only) when SystemSettings.hubSettings() returns no connectionKey. The connectionKey is the bearer token this instance uses to authenticate publishes to the remote Community Hub; without it CommunityHub.createStaticItem cannot be called, so the endpoint aborts before making the outbound request. Surfaced as HTTP 500 with this message.","triggerScenarios":"An admin calls the publish/create endpoint (e.g. for a prompt or slash-command item) before ever configuring the Hub connection key in system settings; the key was cleared or reset in the database; a fresh install where Hub onboarding was skipped.","commonSituations":"New AnythingLLM installs trying to publish to the Community Hub immediately; multi-user instances where the key was configured under a different deployment/database; settings rows lost during migration or manual DB edits.","solutions":["Configure the Community Hub connection key: Admin -> Tools (Community Hub) and paste/save the key obtained from the Hub, then retry the create","Verify persistence after saving (GET the hub settings / reload the admin page) — a key that won't save usually means a DB write failure worth checking in logs","If the key was revoked or lost, re-issue it from the Community Hub portal and update it here"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const { hubSettings } = require('../models/systemSettings');\nconst { connectionKey } = await hubSettings();\nif (!connectionKey) {\n  return response.status(400).json({ success: false, message: 'Configure the Community Hub connection key in Admin -> Tools before publishing' });\n}","typeGuard":"async function hubIsConfigured(): Promise<boolean> { const s = await SystemSettings.hubSettings(); return typeof s.connectionKey === 'string' && s.connectionKey.length > 0; }","tryCatchPattern":"try { await publishToHub(item); } catch (e) { if (/connection key not found/.test(e.message)) { /* route the admin to Community Hub settings instead of retrying */ } else throw e; }","preventionTips":["Make Hub configuration a pre-flight gate in any publish flow (UI or script) — check hubSettings().connectionKey first","After rotating keys, update the instance settings before the next publish attempt","Treat this as a 400-class configuration error in clients; retrying without configuring never succeeds"],"tags":["anythingllm","community-hub","api-key","publishing","settings"],"backgroundTag":"missing-api-key","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}