{"record":{"id":"a3d9e97e525e745d","repo":"koala73/worldmonitor","slug":"countrycode-is-required","errorCode":null,"errorMessage":"countryCode is required","messagePattern":"countryCode is required","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"server/worldmonitor/resilience/v1/get-resilience-score.ts","lineNumber":17,"sourceCode":"import type {\n  ResilienceServiceHandler,\n  ServerContext,\n  GetResilienceScoreRequest,\n  GetResilienceScoreResponse,\n} from '../../../../src/generated/server/worldmonitor/resilience/v1/service_server';\nimport { ValidationError } from '../../../../src/generated/server/worldmonitor/resilience/v1/service_server';\n\nimport { ensureResilienceScoreCached } from './_shared';\n\nexport const getResilienceScore: ResilienceServiceHandler['getResilienceScore'] = async (\n  _ctx: ServerContext,\n  req: GetResilienceScoreRequest,\n): Promise<GetResilienceScoreResponse> => {\n  const countryCode = String(req.countryCode || '').trim().toUpperCase();\n  if (!countryCode) {\n    throw new ValidationError([{ field: 'countryCode', description: 'countryCode is required' }]);\n  }\n  if (!/^[A-Z]{2}$/.test(countryCode)) {\n    throw new ValidationError([{ field: 'countryCode', description: 'countryCode must be a 2-letter ISO 3166-1 alpha-2 code' }]);\n  }\n  return ensureResilienceScoreCached(countryCode);\n};\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/server/worldmonitor/resilience/v1/get-resilience-score.ts#L1-L24","documentation":"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.","triggerScenarios":"Thrown at server/worldmonitor/resilience/v1/get-resilience-score.ts:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include a countryCode in the request","Default the client to the user's selected country so the field is never blank"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}