koala73/worldmonitor · error

Unknown mission preset: ${presetId}

Error message

Unknown mission preset: ${presetId}

What it means

applyMissionPresetToState resolves the requested preset id through getMissionPreset(); the lookup returns undefined for any id that is not one of the bundled presets, and the function throws 'Unknown mission preset: <id>'. It is a fail-fast validation of the presetId argument before any panel/map state is computed.

Source

Thrown at src/services/mission-presets.ts:449

  }
}

export function dismissMissionPresetPrompt(): void {
  try {
    localStorage.setItem(MISSION_PRESET_DISMISSED_KEY, '1');
  } catch {
    // Ignore storage failures.
  }
}

export function applyMissionPresetToState(
  presetId: MissionPresetId,
  currentPanelSettings: Record<string, PanelConfig>,
  defaultLayers: MapLayers = DEFAULT_MAP_LAYERS,
  variant: string = SITE_VARIANT,
): AppliedMissionPreset {
  const preset = getMissionPreset(presetId);
  if (!preset) throw new Error(`Unknown mission preset: ${presetId}`);
  if (!isMissionPresetAvailableForVariant(preset, variant)) {
    throw new Error(`Mission preset ${presetId} is not available on this variant`);
  }

  const variantPanels = getVariantDefaultPanels(variant);
  const variantPanelSet = new Set(variantPanels);
  const matchingPresetPanels = preset.panels.filter((key) => key !== 'map' && variantPanelSet.has(key));
  const useVariantDefaultPanels = matchingPresetPanels.length < MIN_PRESET_PANEL_MATCHES;
  const selectedPanels = useVariantDefaultPanels
    ? withMapPanel(variantPanels)
    : preset.panels.filter((key) => key === 'map' || variantPanelSet.has(key));
  const selectedPanelSet = new Set(selectedPanels);
  const nextPanelSettings: Record<string, PanelConfig> = {};
  const allKeys = new Set([
    ...Object.keys(DEFAULT_PANELS),
    ...Object.keys(ALL_PANELS),
    ...Object.keys(currentPanelSettings),
    ...selectedPanels,

View on GitHub (pinned to 9361220cc0)

Solutions

  1. Use an id from the exported preset list (e.g. via getMissionPresetIds()/the registry) rather than a hand-written string.
  2. Validate the id with getMissionPreset(presetId) before applying and fall back to the default preset when it returns undefined.
  3. Migrate stale stored ids: sanitize loadStoredMissionPreset()/URL state against the current registry and clear unknown values.
  4. For agents, enumerate available presets via the WebMCP picker instead of guessing ids.

Example fix

// before
applyMissionPreset('crisis watch' as MissionPresetId);
// after
const id = 'crisis-watch';
if (!getMissionPreset(id)) {
  console.warn(`Preset ${id} not found, using default`);
}
applyMissionPreset(getMissionPreset(id) ? id : DEFAULT_MISSION_PRESET_ID);
Defensive patterns

Strategy: validation

Validate before calling

import { getMissionPreset } from '../services/mission-presets';
if (!getMissionPreset(presetId)) {
  presetId = DEFAULT_MISSION_PRESET_ID;
}

Type guard

function isKnownPreset(id: string): id is MissionPresetId {
  return getMissionPreset(id as MissionPresetId) != null;
}

Try / catch

try {
  applyMissionPreset(presetId);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Unknown mission preset')) {
    applyMissionPreset(DEFAULT_MISSION_PRESET_ID);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling applyMissionPresetToState (or applyMissionPreset) with an id that is not in the preset registry: a typo, a preset removed/renamed in a newer version, a custom string cast to MissionPresetId, or an id read from stale localStorage/URL state that no longer exists.

Common situations: Passing a human label ('Crisis Watch') instead of the preset id; upgrading the app where stored mission preset ids changed; WebMCP agents guessing preset ids; URL-synced state carrying a deleted preset id.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@9361220cc0 (2026-09-01). Data as JSON: /api/errors/4929ef6b4d05673e. Report an issue: GitHub.