pbakaus/impeccable · error · Error

config.exclude must contain only non-empty strings

Error message

config.exclude must contain only non-empty strings

What it means

Follow-up check for cfg.exclude: when the array is present, every element must be a non-empty string. An exclude array containing '' or a non-string value throws. Same generation pitfalls as empty files entries, but on the optional filter list.

Solutions

  1. Drop empty/non-string entries from exclude so each item is a non-empty string
  2. Filter generated lists before writing: excludes.filter((p) => typeof p === 'string' && p.trim())
  3. Alternatively delete the exclude key — it is optional

Example fix

// before
"exclude": ["dist", ""]

// after
"exclude": ["dist"]
Defensive patterns

Strategy: validation

Validate before calling

const ok = cfg.exclude === undefined
  || (Array.isArray(cfg.exclude) && cfg.exclude.every((f) => typeof f === 'string' && f.length > 0));
if (!ok) throw new TypeError('config.exclude entries must be non-empty strings');

Type guard

const hasCleanExcludeEntries = (cfg) =>
  cfg.exclude === undefined
  || (Array.isArray(cfg.exclude) && cfg.exclude.every((f) => typeof f === 'string' && f.trim() !== ''));

Prevention

When it happens

Trigger: "exclude": ["dist", ""] — trailing empty from a split/join pipeline, or a null/number element inside the array.

Common situations: Programmatically assembled exclude lists that don't filter blanks; template placeholders left in; merging configs where an entry was deleted but left an empty slot.

Related errors


AI-assisted analysis of pbakaus/impeccable@f88b2837a7 (2026-08-18). Data as JSON: /api/errors/6e7efe234df6bf5b. Report an issue: GitHub.

Appendix: source

Thrown at skill/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 f88b2837a7)