Mintplex-Labs/anything-llm · error

Community Hub connection key not found

Error message

Community Hub connection key not found

What it means

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.

Solutions

  1. Configure the Community Hub connection key: Admin -> Tools (Community Hub) and paste/save the key obtained from the Hub, then retry the create
  2. 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
  3. If the key was revoked or lost, re-issue it from the Community Hub portal and update it here
Defensive patterns

Strategy: validation

Validate before calling

const { hubSettings } = require('../models/systemSettings');
const { connectionKey } = await hubSettings();
if (!connectionKey) {
  return response.status(400).json({ success: false, message: 'Configure the Community Hub connection key in Admin -> Tools before publishing' });
}

Type guard

async function hubIsConfigured(): Promise<boolean> { const s = await SystemSettings.hubSettings(); return typeof s.connectionKey === 'string' && s.connectionKey.length > 0; }

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at server/endpoints/communityHub.js:193

        const { connectionKey } = await SystemSettings.hubSettings();
        const items = await CommunityHub.fetchUserItems(connectionKey);
        response.status(200).json({ success: true, ...items });
      } catch (error) {
        console.error(error);
        response.status(500).json({ success: false, error: error.message });
      }
    }
  );

  app.post(
    "/community-hub/:communityHubItemType/create",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const { communityHubItemType } = request.params;
        const { connectionKey } = await SystemSettings.hubSettings();
        if (!connectionKey)
          throw new Error("Community Hub connection key not found");

        const data = reqBody(request);
        const { success, error, itemId } = await CommunityHub.createStaticItem(
          communityHubItemType,
          data,
          connectionKey
        );
        if (!success) throw new Error(error);

        await EventLogs.logEvent(
          "community_hub_publish",
          { itemType: communityHubItemType },
          response.locals?.user?.id
        );
        response
          .status(200)
          .json({ success: true, error: null, item: { id: itemId } });
      } catch (error) {

View on GitHub (pinned to 3aec848f28)