{"record":{"id":"f10ad63760858829","repo":"santifer/career-ops","slug":"apify-token-not-set-enable-apify-in-config-plugi","errorCode":null,"errorMessage":"APIFY_TOKEN not set — enable apify in config/plugins.yml and add the token to .env","messagePattern":"APIFY_TOKEN not set — enable apify in config/plugins\\.yml and add the token to \\.env","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/apify/index.mjs","lineNumber":182,"sourceCode":"  };\n  for (const [k, v] of Object.entries(defaults || {})) {\n    if (!ALLOWED_DEFAULT_KEYS.has(k)) continue;\n    if (!out[k]) out[k] = String(v);\n  }\n  return out;\n}\n\n/** The keyed provider hook. Reads APIFY_TOKEN from the plugin's scoped ctx.env. */\nexport default {\n  provider: {\n    id: 'apify',\n    // Keyed providers never auto-detect (the engine also forces this to null).\n    detect() { return null; },\n\n    async fetch(entry, ctx) {\n      const token = ctx?.env?.APIFY_TOKEN || process.env.APIFY_TOKEN;\n      if (!hasToken(token)) {\n        throw new Error('APIFY_TOKEN not set — enable apify in config/plugins.yml and add the token to .env');\n      }\n      if (!entry.actor) {\n        throw new Error(`apify: entry ${entry.name} missing 'actor' (e.g. misceres/indeed-scraper)`);\n      }\n      if (\n        !entry.field_map ||\n        !isFieldSpec(entry.field_map.title) ||\n        !isFieldSpec(entry.field_map.url) ||\n        (entry.field_map.company != null && !isFieldSpec(entry.field_map.company)) ||\n        (entry.field_map.location != null && !isFieldSpec(entry.field_map.location)) ||\n        (entry.field_map.description != null && !isFieldSpec(entry.field_map.description))\n      ) {\n        throw new Error(\n          `apify: entry ${entry.name} has invalid field_map. Each of title, url, company, ` +\n          `location, description must be a string or a non-empty array of strings. title and url are required.`\n        );\n      }\n","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/plugins/apify/index.mjs#L164-L200","documentation":"The Apify plugin's fetch() requires an Apify API token, read from the plugin context env (ctx.env.APIFY_TOKEN) or process.env.APIFY_TOKEN. If missing, it throws with instructions to enable the plugin in config/plugins.yml and put the token in .env.","triggerScenarios":"Running a scan with the apify plugin configured/enabled but no APIFY_TOKEN in .env or the plugin ctx.env; token present under a different variable name.","commonSituations":"Fresh checkout where .env was never created; enabling the plugin in config/plugins.yml but forgetting the token; CI pipeline missing the secret; docker container without env passthrough.","solutions":["Add APIFY_TOKEN=<your apify token> to .env at the repo root.","Confirm the plugin is enabled in config/plugins.yml with a valid entry.","Ensure the env loader actually loads .env before scan runs; in CI add APIFY_TOKEN to secrets.","Restart the process after editing .env — some runners cache env at startup."],"exampleFix":"// before\n# .env (no apify token)\n// after\nAPIFY_TOKEN=apify_api_XXXXXXXXXXXXXXXX","handlingStrategy":"validation","validationCode":"const token = ctx?.env?.APIFY_TOKEN || process.env.APIFY_TOKEN;\nif (!token) throw new Error('apify plugin needs APIFY_TOKEN in .env');","typeGuard":null,"tryCatchPattern":"try {\n  await scan(entry);\n} catch (e) {\n  if (String(e.message).includes('APIFY_TOKEN not set')) {\n    console.error('Enable apify in config/plugins.yml and add APIFY_TOKEN to .env');\n    return;\n  }\n  throw e;\n}","preventionTips":["Run a preflight env check before starting scans that lists required plugin env vars.","Keep .env.example updated with APIFY_TOKEN documented.","Verify plugin enablement in config/plugins.yml matches .env state.","In CI, wire APIFY_TOKEN as a secret and assert it at job start."],"tags":["apify","env","config","token"],"backgroundTag":"missing-env-var","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}