pbakaus/impeccable · warning · Error

config.exclude must contain only non-empty strings

Error message

config.exclude must contain only non-empty strings

What it means

Fifth validateConfig() check: when cfg.exclude is an array, every element must be a non-empty string. Mirrors the files check (error 48) but for the optional exclude list. globToRegex() compiles each entry into a RegExp, so a non-string would throw inside the regex builder with a less helpful message.

Source

Thrown at plugin/skills/impeccable/scripts/live-inject.mjs:462

// ---------------------------------------------------------------------------
// 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");
  }
}

// ---------------------------------------------------------------------------
// Auto-execute
// ---------------------------------------------------------------------------

const _running = process.argv[1];

View on GitHub (pinned to d14711ae3d)

Solutions

  1. Ensure every exclude entry is a non-empty glob string.
  2. Filter: exclude.filter((e) => typeof e === 'string' && e.trim()).
  3. Run `node live-inject.mjs --check` to find the offending entry.
  4. Regenerate config via setup if hand-editing is error-prone.

Example fix

// before
{ "exclude": ["dist\/**", false], ... }

// after
{ "exclude": ["dist\/**"], ... }
Defensive patterns

Strategy: validation

Validate before calling

function areExcludeEntriesValid(cfg) {
  return cfg?.exclude === undefined
    || (Array.isArray(cfg.exclude)
      && cfg.exclude.every((f) => typeof f === 'string' && f.length > 0));
}
if (!areExcludeEntriesValid(cfg)) {
  cfg.exclude = cfg.exclude.filter((f) => typeof f === 'string' && f);
}

Type guard

function isNonEmptyStringArrayOrNull(value) {
  return value === undefined || isNonEmptyStringArray(value);
}

Try / catch

try {
  validateConfig(cfg);
} catch (err) {
  if (/config\.exclude must contain only non-empty strings/.test(err.message)) {
    cfg.exclude = cfg.exclude.filter((f) => typeof f === 'string' && f);
    validateConfig(cfg);
  }
  throw err;
}

Prevention

When it happens

Trigger: ["node_modules\/**", 0], [""], ["dist\/**", null]. Same typed-wrong shape as error 48 but on the exclude field.

Common situations: Programmatic exclude build pushed a non-string; placeholder '' left during editing; boolean toggles mis-serialised into the array.

Related errors


AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13). Data as JSON: /api/errors/ae277e0440860da2. Report an issue: GitHub.