pbakaus/impeccable · error · Error
config.files must contain only non-empty strings
Error message
config.files must contain only non-empty strings
What it means
Third validateConfig() check: every element of cfg.files must be a non-empty string. Fires when the array contains a non-string (number, null, object, boolean) or an empty string ''. resolveFiles() and the tag injector both treat each entry as a path/glob string, so a non-string would crash downstream.
Source
Thrown at plugin/skills/impeccable/scripts/live-inject.mjs:455
} else {
re += c;
i += 1;
}
}
return new RegExp('^' + re + '$');
}
// ---------------------------------------------------------------------------
// Core operations
// ---------------------------------------------------------------------------
function validateConfig(cfg) {
if (!cfg || typeof cfg !== 'object') throw new Error('config.json must be an object');
if (!Array.isArray(cfg.files) || cfg.files.length === 0) {
throw new Error('config.files (non-empty string array) required');
}
if (!cfg.files.every((f) => typeof f === 'string' && f.length > 0)) {
throw new Error('config.files must contain only non-empty strings');
}
if (cfg.exclude !== undefined) {
if (!Array.isArray(cfg.exclude)) {
throw new Error('config.exclude, if present, must be a string array');
}
if (!cfg.exclude.every((f) => typeof f === 'string' && f.length > 0)) {
throw new Error('config.exclude must contain only non-empty strings');
}
}
if (typeof cfg.insertBefore !== 'string' && typeof cfg.insertAfter !== 'string') {
throw new Error('config.insertBefore or config.insertAfter (string) required');
}
if (cfg.commentSyntax !== 'html' && cfg.commentSyntax !== 'jsx') {
throw new Error("config.commentSyntax must be 'html' or 'jsx'");
}
if (cfg.cspChecked !== undefined && typeof cfg.cspChecked !== 'boolean') {
throw new Error("config.cspChecked, if present, must be a boolean");
}View on GitHub (pinned to d14711ae3d)
Solutions
- Ensure every element of config.files is a non-empty string path or glob.
- Filter before serialising: files.filter((f) => typeof f === 'string' && f.trim()).
- Run `node live-inject.mjs --check` to locate the bad entry.
- Regenerate the config via setup rather than hand-editing typed values.
Example fix
// before
{ "files": ["index.html", 0], ... }
// after
{ "files": ["index.html"], ... } Defensive patterns
Strategy: validation
Validate before calling
function areFilesAllStrings(cfg) {
return Array.isArray(cfg?.files)
&& cfg.files.every((f) => typeof f === 'string' && f.length > 0);
}
if (!areFilesAllStrings(cfg)) {
cfg.files = cfg.files.filter((f) => typeof f === 'string' && f.trim());
} Type guard
/** True when every files entry is a non-empty string. */
function isNonEmptyStringArray(value) {
return Array.isArray(value)
&& value.every((v) => typeof v === 'string' && v.length > 0);
} Try / catch
try {
validateConfig(cfg);
} catch (err) {
if (/config\.files must contain only non-empty strings/.test(err.message)) {
cfg.files = cfg.files.filter((f) => typeof f === 'string' && f);
validateConfig(cfg); // retry once
}
throw err;
} Prevention
- Filter config.files before serialising: files.filter((f) => typeof f === 'string' && f.trim()).
- Don't push numbers (ports) or nulls into the files array during programmatic builds.
- Validate with `node live-inject.mjs --check` after edits.
When it happens
Trigger: ["index.html", 42], ["index.html", null], [""], ["index.html", ""]. A trailing comma in JSON is a parse error (different code path), but a hand-written array with mixed types parses fine and lands here.
Common situations: Programmatic config build that pushed a number (port) or undefined into the array; copy-paste left a placeholder ''; a templating system serialised a null for a missing value. JSON.parse of a trailing-comma array throws, so this specifically means syntactically valid but typed-wrong content.
Related errors
- config.json must be an object
- config.files (non-empty string array) required
- config.exclude, if present, must be a string array
- config.exclude must contain only non-empty strings
- config.insertBefore or config.insertAfter (string) required
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/54b1158f3999405b.
Report an issue: GitHub.