santifer/career-ops · error
must be an array in
Error message
${key} must be an array in ${path} What it means
loadFactConfig() in verify-cv-facts.mjs validates the fact-checker's JSON config: each of allow_metrics, allow_facts, forbidden_phrases, warn_phrases must be an array. If the key is present, non-null, and not an array, it throws '${key} must be an array in ${path}'.
Solutions
- Open the config file named in the error and make the offending key a JSON array
- Convert a comma-separated string into an array of strings: ["foo", "bar"]
- Validate the JSON: node -e "JSON.parse(require('fs').readFileSync('<path>','utf8'))" and inspect the key's type
- If the key is optional, either remove it or set it to []
Example fix
// before (config.json)
{ "forbidden_phrases": " fabricated, invented " }
// after
{ "forbidden_phrases": ["fabricated", "invented"] } Defensive patterns
Strategy: validation
Validate before calling
const cfg = JSON.parse(readFileSync(path, 'utf-8'));
for (const key of ['allow_metrics','allow_facts','forbidden_phrases','warn_phrases']) {
if (cfg[key] != null && !Array.isArray(cfg[key])) {
throw new Error(`${key} must be an array in ${path} (got ${typeof cfg[key]})`);
}
} Type guard
const isArrayKey = (cfg, key) => cfg[key] == null || Array.isArray(cfg[key]);
Try / catch
try {
const { config } = loadFactConfig(configPath);
} catch (err) {
if (err.message.includes('must be an array')) {
console.error(`Fix config: ${err.message}`);
process.exit(1);
}
throw err;
} Prevention
- Write config list values as JSON arrays of strings, never comma-separated strings
- Lint/JSON-schema-validate the config file before use
- Keep config edits in one place and re-validate after every change
- If migrating from YAML, convert unquoted list syntax explicitly to JSON arrays
When it happens
Trigger: A cv-facts config JSON where a list key is a string ("forbidden_phrases": "foo, bar"), an object, or a number instead of a JSON array. Also hit when a hand-edited config swaps an array for a single value.
Common situations: Hand-editing the config and writing comma-separated strings instead of arrays; YAML-style unquoted list syntax saved into a .json file; tool migration writing object maps instead of arrays.
Related errors
- apify: entry has invalid field_map. Each of title, url…
- apify: entry missing 'actor' (e.g. misceres/indeed-scraper)
- arbeitnow: invalid URL
- ashby: invalid URL
- bamboohr: invalid URL
AI-assisted analysis of santifer/career-ops@e7abd431fc (2026-09-16).
Data as JSON: /api/errors/ec7567adc2e4d282.
Report an issue: GitHub.
Appendix: source
Thrown at verify-cv-facts.mjs:804
* file loaded the phrase check cannot fail — and a gate that is DISABLED then
* reads exactly like a gate that RAN AND FOUND NOTHING. `missing` is the one bit
* that tells them apart; callers surface it (#3894).
*
* Nothing here turns a missing config into an error. A user who has never
* written a cv-facts.json is in a normal state; they just should not be left
* believing a gate is protecting them when none is loaded.
*
* @param {string} path absolute path to the configuration file
* @returns {{missing: boolean, config: {allow_metrics: string[], allow_facts: string[], forbidden_phrases: string[], warn_phrases: string[]}}}
* @throws when the file exists but is unparseable or has a non-array key
*/
export function loadFactConfig(path) {
const keys = ['allow_metrics', 'allow_facts', 'forbidden_phrases', 'warn_phrases'];
if (!existsSync(path)) return { missing: true, config: Object.fromEntries(keys.map(key => [key, []])) };
const config = JSON.parse(readFileSync(path, 'utf-8'));
for (const key of keys) {
if (config[key] == null) config[key] = [];
else if (!Array.isArray(config[key])) throw new Error(`${key} must be an array in ${path}`);
}
return { missing: false, config };
}
/** Resolve a CLI or configuration path relative to the selected working directory. */
function resolveInputPath(path, cwd = process.cwd()) {
return isAbsolute(path) ? path : join(cwd, path);
}
/** Check a normalized fact as a complete token or phrase, not a substring. */
function sourceContainsFact(sourceText, value) {
const escaped = value
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
.replace(/\s+/g, '\\s+');
return new RegExp(`(?:^|[^\\p{L}\\p{N}+#/-])${escaped}(?=$|[^\\p{L}\\p{N}+#/-])`, 'iu').test(sourceText);
}
/**View on GitHub (pinned to e7abd431fc)