{"record":{"id":"4386c49b5bd97032","repo":"koala73/worldmonitor","slug":"failed-to-fetch-job-status","errorCode":null,"errorMessage":"Failed to fetch job status","messagePattern":"Failed to fetch job status","errorType":"http","errorClass":"ApiError","httpStatus":502,"severity":"error","filePath":"server/worldmonitor/scenario/v1/get-scenario-status.ts","lineNumber":78,"sourceCode":"}\n\nexport async function getScenarioStatus(\n  ctx: ServerContext,\n  req: GetScenarioStatusRequest,\n): Promise<GetScenarioStatusResponse> {\n  await requirePremiumRpcAccess(ctx.request, ApiError, 'PRO subscription required');\n\n  const jobId = req.jobId ?? '';\n  if (!JOB_ID_RE.test(jobId)) {\n    throw new ValidationError([{ field: 'jobId', description: 'Invalid or missing jobId' }]);\n  }\n\n  // Worker writes under the raw (unprefixed) key, so we must read raw.\n  let envelope: WorkerResultEnvelope | null = null;\n  try {\n    envelope = await getRawJson(`scenario-result:${jobId}`) as WorkerResultEnvelope | null;\n  } catch {\n    throw new ApiError(502, 'Failed to fetch job status', '');\n  }\n\n  if (!envelope) {\n    return { status: 'pending', error: '' };\n  }\n\n  const status = typeof envelope.status === 'string' ? envelope.status : 'pending';\n\n  if (status === 'done') {\n    const result = coerceResult(envelope.result);\n    return { status: 'done', result, error: '' };\n  }\n\n  if (status === 'failed') {\n    const error = typeof envelope.error === 'string' ? envelope.error : 'computation_error';\n    return { status: 'failed', error };\n  }\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/server/worldmonitor/scenario/v1/get-scenario-status.ts#L60-L96","documentation":"Cache-read failure in getScenarioStatus: getRawJson could not fetch the worker result envelope for scenario-result:<jobId> (it returned null rather than a parseable envelope). The job result is not (yet) available — the worker has not finished, expired, or failed to write its result.","triggerScenarios":"Thrown at server/worldmonitor/scenario/v1/get-scenario-status.ts:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after a delay — the scenario worker may still be computing","If it persists past the job TTL, the worker failed; re-run the scenario to produce a fresh job","Check worker logs for the jobId to distinguish slow from failed"],"exampleFix":null,"handlingStrategy":"retry","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-14T05:17:10.506Z"}