santifer/career-ops · error · Error
apify: entry ${entry.name} has invalid field_map. Each of ti
Error message
apify: entry ${entry.name} has invalid field_map. Each of title, url, company, location, description must be a string or a non-empty array of strings. title and url are required. What it means
Thrown by the apify provider's `fetch` hook (plugins/apify/index.mjs:195) when a portals.yml entry's `field_map` is missing, or when `title`/`url` are not valid field specs, or when any of the optional `company`/`location`/`description` fields (if present) are not valid field specs. A 'field spec' is a string or a non-empty array of strings (checked by `isFieldSpec`) naming the JSON path(s) in the actor's dataset items to extract. title and url are required; the others are optional but, if present, must be valid.
Source
Thrown at plugins/apify/index.mjs:195
detect() { return null; },
async fetch(entry, ctx) {
const token = ctx?.env?.APIFY_TOKEN || process.env.APIFY_TOKEN;
if (!hasToken(token)) {
throw new Error('APIFY_TOKEN not set — enable apify in config/plugins.yml and add the token to .env');
}
if (!entry.actor) {
throw new Error(`apify: entry ${entry.name} missing 'actor' (e.g. misceres/indeed-scraper)`);
}
if (
!entry.field_map ||
!isFieldSpec(entry.field_map.title) ||
!isFieldSpec(entry.field_map.url) ||
(entry.field_map.company != null && !isFieldSpec(entry.field_map.company)) ||
(entry.field_map.location != null && !isFieldSpec(entry.field_map.location)) ||
(entry.field_map.description != null && !isFieldSpec(entry.field_map.description))
) {
throw new Error(
`apify: entry ${entry.name} has invalid field_map. Each of title, url, company, ` +
`location, description must be a string or a non-empty array of strings. title and url are required.`
);
}
const opts = { token };
if (entry.timeout_ms != null) opts.timeoutMs = entry.timeout_ms;
const items = await runActor(entry.actor, entry.input || {}, opts);
const useLocalJd = entry.field_map.description != null;
const sourceLabel = String(entry.actor || 'apify').replace(/[^a-z0-9]+/gi, '-').toLowerCase();
return items
.map(item => {
const normalized = normalizeItem(item, entry.field_map, entry.defaults);
if (!normalized.title || !normalized.url) return null;
if (!isHttpsUrl(normalized.url)) return null;
if (!useLocalJd) return normalized;View on GitHub (pinned to 9b17a8ac97)
Solutions
- Inspect a sample dataset item from the actor (Apify console) to learn the real field names, then set field_map accordingly.
- Ensure `title` and `url` are strings (or non-empty arrays of strings) matching dataset keys.
- For optional fields, either omit them or use valid string/array-of-strings specs.
- Remove empty-array field_map entries (`[]` is invalid).
Example fix
# before — portals.yml
- name: indeed
provider: apify
actor: misceres/indeed-scraper
field_map:
title: positionTitle # wrong key name → empty extraction
url: [] # empty array → invalid
# after (keys match the actor's dataset item shape)
- name: indeed
provider: apify
actor: misceres/indeed-scraper
field_map:
title: title
url: url
company: company
location: location
description: description Defensive patterns
Strategy: type-guard
Validate before calling
function isFieldSpec(v) {
return typeof v === 'string' && v.length > 0 ||
(Array.isArray(v) && v.length > 0 && v.every(x => typeof x === 'string' && x.length > 0));
}
function validateFieldMap(entry) {
const fm = entry.field_map;
if (!fm || !isFieldSpec(fm.title) || !isFieldSpec(fm.url)) {
throw new Error(`Entry '${entry.name}' field_map requires valid title and url.`);
}
for (const k of ['company', 'location', 'description']) {
if (fm[k] != null && !isFieldSpec(fm[k])) {
throw new Error(`Entry '${entry.name}' field_map.${k} is invalid.`);
}
}
}
portals.filter(p => p.provider === 'apify').forEach(validateFieldMap); Type guard
/** @param {unknown} v */
function isFieldSpec(v) {
if (typeof v === 'string') return v.length > 0;
if (Array.isArray(v)) return v.length > 0 && v.every(x => typeof x === 'string' && x.length > 0);
return false;
} Try / catch
try {
await provider.fetch(entry, ctx);
} catch (err) {
if (/invalid field_map/.test(err.message)) {
console.error(`Config error: ${err.message}`);
process.exitCode = 2;
} else throw err;
} Prevention
- Inspect a sample dataset item on the Apify console to learn real field names before writing field_map.
- Lint field_map with isFieldSpec in CI for every apify entry.
- Omit optional fields rather than setting them to empty arrays.
When it happens
Trigger: The entry has no `field_map`, or `field_map.title`/`field_map.url` is missing/non-string/empty-array, or an optional field is set to a number/object/empty array. The compound `if` evaluates true and throws.
Common situations: field_map omitted entirely; title/url misspelled or referencing a field the actor doesn't output; an optional field set to `null`-equivalent or an empty array `[]`; YAML formatting that made a field an object instead of a string.
Related errors
- apify: entry ${entry.name} missing 'actor' (e.g. misceres/in
- apify: invalid actorId ${JSON.stringify(actorId)}. Expected
- apify: invalid timeoutMs ${JSON.stringify(timeoutMs)} (must
- APIFY_TOKEN not set — enable apify in config/plugins.yml and
- Invalid page budget "${maxPages}". Use a positive integer.
AI-assisted analysis of santifer/career-ops@9b17a8ac97 (2026-08-13).
Data as JSON: /api/errors/2a26e3b8b0a8685f.
Report an issue: GitHub.