koala73/worldmonitor · error · ValidationError
countryCode is required
Error message
countryCode is required
What it means
Request validation in the resilience-score handler: req.countryCode is missing or empty after String() coercion. The score is per-country, so with no country there is nothing to compute and the request is rejected before cache access.
Source
Thrown at server/worldmonitor/resilience/v1/get-resilience-score.ts:17
import type {
ResilienceServiceHandler,
ServerContext,
GetResilienceScoreRequest,
GetResilienceScoreResponse,
} from '../../../../src/generated/server/worldmonitor/resilience/v1/service_server';
import { ValidationError } from '../../../../src/generated/server/worldmonitor/resilience/v1/service_server';
import { ensureResilienceScoreCached } from './_shared';
export const getResilienceScore: ResilienceServiceHandler['getResilienceScore'] = async (
_ctx: ServerContext,
req: GetResilienceScoreRequest,
): Promise<GetResilienceScoreResponse> => {
const countryCode = String(req.countryCode || '').trim().toUpperCase();
if (!countryCode) {
throw new ValidationError([{ field: 'countryCode', description: 'countryCode is required' }]);
}
if (!/^[A-Z]{2}$/.test(countryCode)) {
throw new ValidationError([{ field: 'countryCode', description: 'countryCode must be a 2-letter ISO 3166-1 alpha-2 code' }]);
}
return ensureResilienceScoreCached(countryCode);
};
View on GitHub (pinned to eeab0a219f)
Solutions
- Include a countryCode in the request
- Default the client to the user's selected country so the field is never blank
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/worldmonitor/resilience/v1/get-resilience-score.ts:17 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21).
Data as JSON: /api/errors/a3d9e97e525e745d.
Report an issue: GitHub.