{"record":{"id":"a434332173cc5c16","repo":"santifer/career-ops","slug":"apify-actor-actorid-finished-with-status-run","errorCode":null,"errorMessage":"Apify actor ${actorId} finished with status ${run.status}${reason}","messagePattern":"Apify actor (.+?) finished with status (.+?)(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/apify/_apify.mjs","lineNumber":199,"sourceCode":"  if (!Array.isArray(items)) {\n    throw new Error(`Apify run ${runId} returned non-array dataset payload`);\n  }\n  return items;\n}\n\nexport async function runActor(actorId, input, { timeoutMs = DEFAULT_RUN_TIMEOUT_MS, token = process.env.APIFY_TOKEN } = {}) {\n  if (!token) throw new Error('APIFY_TOKEN not set');\n  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n    throw new Error(`apify: invalid timeoutMs ${JSON.stringify(timeoutMs)} (must be a positive finite number of milliseconds)`);\n  }\n  // Single deadline shared across startRun → waitForRun → fetchDatasetItems so\n  // the caller's timeoutMs is the end-to-end ceiling, not just the wait loop.\n  const deadline = Date.now() + timeoutMs;\n  const runId = await startRun(actorId, input, token, deadline);\n  const run = await waitForRun(runId, token, deadline, timeoutMs);\n  if (run.status !== 'SUCCEEDED') {\n    const reason = run.statusMessage ? `: ${run.statusMessage}` : '';\n    throw new Error(`Apify actor ${actorId} finished with status ${run.status}${reason}`);\n  }\n  return await fetchDatasetItems(runId, token, deadline);\n}\n","sourceCodeStart":181,"sourceCodeEnd":203,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/plugins/apify/_apify.mjs#L181-L203","documentation":"Thrown by `runActor` (plugins/apify/_apify.mjs:199) when the actor run reaches a terminal status other than SUCCEEDED — i.e. FAILED, ABORTED, or TIMED-OUT. The `waitForRun` loop returns the run object once status is in TERMINAL_STATUSES; runActor then checks `if (run.status !== 'SUCCEEDED')` and throws, appending `run.statusMessage` as `: <reason>` if present. The dataset is not fetched on failure.","triggerScenarios":"The actor finished but failed (input error, scraper bug), was aborted (manually or by Apify), or hit Apify's own run timeout. waitForRun returns the terminal run, and runActor rejects.","commonSituations":"Bad actor input (wrong field names, missing required input); the target site changed and the scraper broke; Apify aborted the run due to proxy/quota exhaustion; the actor timed out internally on Apify's side before your timeoutMs.","solutions":["Read the statusMessage suffix — Apify usually states the failure cause.","Open the run on the Apify console (runId is in the message) for full logs.","Fix the actor input (field_map / input in portals.yml) to match the actor's expected schema.","If the actor itself is broken, switch to an updated actor or contact its maintainer."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const items = await runActor(actorId, input, opts);\n} catch (err) {\n  if (/finished with status (FAILED|ABORTED|TIMED-OUT)/.test(err.message)) {\n    console.error(`Apify actor ${actorId} did not succeed: ${err.message}`);\n    // inspect the runId in the message on the Apify console for logs\n  } else throw err;\n}","preventionTips":["Validate actor input against the actor's documented schema before running.","Monitor actor health on the Apify console; switch actors when a target site changes."],"tags":["apify","actor-failure","api","configuration"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}