BloopAI/vibe-kanban · error · Error

Profile key not found

Error message

Profile key not found

What it means

loadMcpServersForProfile in McpSettingsSection throws 'Profile key not found' when it cannot find the key in the `profiles` record (Record<string, ExecutorProfile>) whose value reference-equals the currently selected profile. The key is needed as the `executor` identifier for machineClient.loadMcpServers. This happens when the selected ExecutorProfile object no longer comes from the current profiles map (stale reference after profiles reload).

Solutions

  1. Reload the settings page so selectedProfile re-initializes from the fresh profiles map
  2. Verify the executor in config.executor_profile exists in profiles; fix ~/.vibe/config.toml if it names an unknown executor
  3. Wait for profiles to load before rendering the MCP section (guard on profiles != null)
  4. Harden the lookup: key profiles by executor name instead of object identity when wiring setSelectedProfile

Example fix

// before
setSelectedProfile(profiles[config.executor_profile.executor]); // captured object
// after (lookup by key at use time)
const selectedProfileKey = selectedExecutorKey; // store the key, e.g. 'claude'
const profile = profiles?.[selectedExecutorKey];
Defensive patterns

Strategy: type-guard

Validate before calling

// before the lookup, bail early instead of throwing:
if (!profiles || Object.keys(profiles).length === 0) { setMcpLoading(false); return; }

Type guard

function findProfileKey(profiles: Record<string, ExecutorProfile> | null | undefined, profile: ExecutorProfile): string | null {
  if (!profiles) return null;
  const entry = Object.entries(profiles).find(([, p]) => p === profile);
  return entry?.[0] ?? null;
}

Try / catch

try {
  const profileKey = findProfileKey(profiles, selectedProfile);
  if (!profileKey) {
    setMcpError('Profile configuration changed — reload settings to reselect the agent.');
    return;
  }
  const result = await machineClient.loadMcpServers({ executor: profileKey as BaseCodingAgent });
} catch (err) {
  console.error('Error loading MCP servers:', err);
}

Prevention

When it happens

Trigger: The effect runs with a selectedProfile set, but profiles is null/undefined, or no value in profiles === selectedProfile (strict equality) — typically profiles were refetched/replaced after the profile object was captured, or config.executor_profile references an executor absent from profiles.

Common situations: User system config reloaded while the settings page was open, replacing profile objects; selected executor removed/renamed in config; profiles still loading (null) when the effect fires; hot-module reload recreating objects in dev.

Related errors


AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29). Data as JSON: /api/errors/82db28a1695360a6. Report an issue: GitHub.

Appendix: source

Thrown at packages/web-core/src/shared/dialogs/settings/settings/McpSettingsSection.tsx:74

      } else if (Object.keys(profiles).length > 0) {
        setSelectedProfile(Object.values(profiles)[0]);
      }
    }
  }, [config?.executor_profile, profiles, selectedProfile]);

  // Load MCP configuration when selected profile changes
  useEffect(() => {
    const loadMcpServersForProfile = async (profile: ExecutorProfile) => {
      setMcpLoading(true);
      setMcpError(null);
      setMcpConfigPath('');

      try {
        const profileKey = profiles
          ? Object.keys(profiles).find((key) => profiles[key] === profile)
          : null;
        if (!profileKey) {
          throw new Error('Profile key not found');
        }

        if (!machineClient) {
          throw new Error('Machine client is required');
        }

        const result = await machineClient.loadMcpServers({
          executor: profileKey as BaseCodingAgent,
        });
        setMcpConfig(result.mcp_config);
        const fullConfig = McpConfigStrategyGeneral.createFullConfig(
          result.mcp_config
        );
        const configJson = JSON.stringify(fullConfig, null, 2);
        setMcpServers(configJson);
        setOriginalMcpServers(configJson);
        setMcpConfigPath(result.config_path);
      } catch (err: unknown) {

View on GitHub (pinned to 4deb7eca8f)