koala73/worldmonitor · error · ValidationError
scenarioId is required
Error message
scenarioId is required
What it means
Request validation in runScenario: req.scenarioId is empty after trim. The premium access check has already passed; the validation fails because no scenario template was named, so there is nothing to enqueue for the worker.
Source
Thrown at server/worldmonitor/scenario/v1/run-scenario.ts:36
function generateJobId(): string {
const ts = Date.now();
let suffix = '';
const array = new Uint8Array(8);
crypto.getRandomValues(array);
for (const byte of array) suffix += JOB_ID_CHARSET[byte % JOB_ID_CHARSET.length];
return `scenario:${ts}:${suffix}`;
}
export async function runScenario(
ctx: ServerContext,
req: RunScenarioRequest,
): Promise<RunScenarioResponse> {
await requirePremiumRpcAccess(ctx.request, ApiError, 'PRO subscription required');
const scenarioId = (req.scenarioId ?? '').trim();
if (!scenarioId) {
throw new ValidationError([{ field: 'scenarioId', description: 'scenarioId is required' }]);
}
if (!getScenarioTemplate(scenarioId)) {
throw new ValidationError([{ field: 'scenarioId', description: `Unknown scenario: ${scenarioId}` }]);
}
const iso2 = req.iso2 ? req.iso2.trim() : '';
if (iso2 && !/^[A-Z]{2}$/.test(iso2)) {
throw new ValidationError([{ field: 'iso2', description: 'iso2 must be a 2-letter uppercase country code' }]);
}
// Queue-depth backpressure. Raw key: worker reads it unprefixed, so we must too.
const [depthEntry] = await runRedisPipeline([['LLEN', QUEUE_KEY]], true);
const depth = typeof depthEntry?.result === 'number' ? depthEntry.result : 0;
if (depth > MAX_QUEUE_DEPTH) {
throw new ApiError(429, 'Scenario queue is at capacity, please try again later', '');
}
const jobId = generateJobId();View on GitHub (pinned to eeab0a219f)
Solutions
- Pass a non-empty scenarioId from the scenario catalog
- Default the UI to a selected scenario so the field cannot be submitted blank
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/worldmonitor/scenario/v1/run-scenario.ts:36 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/24fccf2a269008b5.
Report an issue: GitHub.