koala73/worldmonitor · error · SafeWebMcpError

iso2 must be an ISO 3166-1 alpha-2 code, such as "DE" or "IR

Error message

iso2 must be an ISO 3166-1 alpha-2 code, such as "DE" or "IR".

What it means

Validation error text for the open_country_brief WebMCP tool's iso2 argument. The guard fires when iso2 is not a two-letter uppercase ISO 3166-1 alpha-2 country code (lowercase, three letters, digits, or wrong casing), as enforced by the ^[A-Z]{2}$ pattern; examples like DE or IR show the expected format. Opening the brief can consume daily briefing quota; use focus_country to only pan the map.

Source

Thrown at src/services/webmcp.ts:1704

      description:
        'Open the intelligence brief panel for a country by ISO 3166-1 alpha-2 code (e.g. "DE", "IR"). Routes the user to the country deep-dive view; the brief itself is fetched by the same path a click would take. This can consume daily briefing quota. To only pan the map, use focus_country.',
      inputSchema: {
        type: 'object',
        properties: {
          iso2: {
            type: 'string',
            description: 'ISO 3166-1 alpha-2 country code, uppercase.',
            pattern: '^[A-Z]{2}$',
          },
        },
        required: ['iso2'],
        additionalProperties: false,
      },
      annotations: { readOnlyHint: false },
      execute: withInvocationLogging(WEBMCP_SPA_TOOL.openCountryBrief, async (args, extra) => {
        const iso2 = typeof args.iso2 === 'string' ? args.iso2.toUpperCase() : '';
        if (!ISO2.test(iso2)) {
          throw new SafeWebMcpError(
            'iso2 must be an ISO 3166-1 alpha-2 code, such as "DE" or "IR".',
            'validation',
          );
        }
        const name = boundedText(app.resolveCountryName(iso2), 160) || iso2;
        const opened = await app.openCountryBriefByCode(iso2, name, extra);
        if (opened !== true) {
          throw new SafeWebMcpError(
            'The requested country brief did not become visible.',
            'unavailable',
          );
        }
        return `Opened intelligence brief for ${name} (${iso2}).`;
      }, trackEvent),
    },
    {
      name: WEBMCP_SPA_TOOL.openSearch,
      title: 'Open Search',

View on GitHub (pinned to 9361220cc0)

Solutions

  1. Pass a valid ISO 3166-1 alpha-2 country code: exactly two uppercase letters (e.g. "DE", "IR", "US"). Uppercase the input and trim whitespace before validating.
  2. Validate against /^[A-Z]{2}$/ plus, if strictness is required, a known-code list; reject early with this message and the received value so the caller can self-correct.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/services/webmcp.ts:556 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@9361220cc0 (2026-08-27). Data as JSON: /api/errors/97b964998f533c0f. Report an issue: GitHub.