koala73/worldmonitor · error

Mission preset ${presetId} is not available on this variant

Error message

Mission preset ${presetId} is not available on this variant

What it means

After the preset id resolves, applyMissionPresetToState checks isMissionPresetAvailableForVariant(preset, variant) and throws when the preset is gated off for the current site variant (e.g. a preset only shipped on the full site but requested on a minimal/region variant). The preset exists but is not licensed for this deployment variant.

Source

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

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. Filter preset choices through isMissionPresetAvailableForVariant(preset, SITE_VARIANT) before applying.
  2. Omit the variant argument to use the built-in SITE_VARIANT default instead of a mismatched literal.
  3. Fall back to a universally available preset when the requested one is gated off for the variant.
  4. Keep preset availability lists in sync when renaming or adding variants.

Example fix

// before
applyMissionPreset('maritime-ops', 'mobile-lite'); // not available on this variant
// after
const preset = getMissionPreset('maritime-ops');
if (preset && isMissionPresetAvailableForVariant(preset, SITE_VARIANT)) {
  applyMissionPreset('maritime-ops');
} else {
  applyMissionPreset(DEFAULT_MISSION_PRESET_ID);
}
Defensive patterns

Strategy: validation

Validate before calling

import { getMissionPreset, isMissionPresetAvailableForVariant, SITE_VARIANT } from '../services/mission-presets';
const preset = getMissionPreset(presetId);
if (!preset || !isMissionPresetAvailableForVariant(preset, SITE_VARIANT)) {
  presetId = DEFAULT_MISSION_PRESET_ID;
}

Type guard

function canApplyPreset(id: MissionPresetId, variant: string = SITE_VARIANT): boolean {
  const p = getMissionPreset(id);
  return !!p && isMissionPresetAvailableForVariant(p, variant);
}

Try / catch

try {
  applyMissionPreset(presetId);
} catch (e) {
  if (e instanceof Error && /is not available on this variant/.test(e.message)) {
    applyMissionPreset(DEFAULT_MISSION_PRESET_ID);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling applyMissionPresetToState/applyMissionPreset with a valid presetId whose availability list excludes the current SITE_VARIANT (or an explicitly passed variant string), e.g. forcing a variant-specific preset in a build where it is disabled.

Common situations: Hardcoding a preset id that exists on the main site but not on a stripped-down variant; passing the wrong variant argument; stored preset ids synced from another variant's localStorage; variant renamed in config while preset availability lists still use old names.

Related errors


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