{"record":{"id":"54b1158f3999405b","repo":"pbakaus/impeccable","slug":"config-files-must-contain-only-non-empty-strings","errorCode":null,"errorMessage":"config.files must contain only non-empty strings","messagePattern":"config\\.files must contain only non-empty strings","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/scripts/live-inject.mjs","lineNumber":455,"sourceCode":"    } else {\n      re += c;\n      i += 1;\n    }\n  }\n  return new RegExp('^' + re + '$');\n}\n\n// ---------------------------------------------------------------------------\n// Core operations\n// ---------------------------------------------------------------------------\n\nfunction validateConfig(cfg) {\n  if (!cfg || typeof cfg !== 'object') throw new Error('config.json must be an object');\n  if (!Array.isArray(cfg.files) || cfg.files.length === 0) {\n    throw new Error('config.files (non-empty string array) required');\n  }\n  if (!cfg.files.every((f) => typeof f === 'string' && f.length > 0)) {\n    throw new Error('config.files must contain only non-empty strings');\n  }\n  if (cfg.exclude !== undefined) {\n    if (!Array.isArray(cfg.exclude)) {\n      throw new Error('config.exclude, if present, must be a string array');\n    }\n    if (!cfg.exclude.every((f) => typeof f === 'string' && f.length > 0)) {\n      throw new Error('config.exclude must contain only non-empty strings');\n    }\n  }\n  if (typeof cfg.insertBefore !== 'string' && typeof cfg.insertAfter !== 'string') {\n    throw new Error('config.insertBefore or config.insertAfter (string) required');\n  }\n  if (cfg.commentSyntax !== 'html' && cfg.commentSyntax !== 'jsx') {\n    throw new Error(\"config.commentSyntax must be 'html' or 'jsx'\");\n  }\n  if (cfg.cspChecked !== undefined && typeof cfg.cspChecked !== 'boolean') {\n    throw new Error(\"config.cspChecked, if present, must be a boolean\");\n  }","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/plugin/skills/impeccable/scripts/live-inject.mjs#L437-L473","documentation":"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.","triggerScenarios":"[\"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{ \"files\": [\"index.html\", 0], ... }\n\n// after\n{ \"files\": [\"index.html\"], ... }","handlingStrategy":"validation","validationCode":"function areFilesAllStrings(cfg) {\n  return Array.isArray(cfg?.files)\n    && cfg.files.every((f) => typeof f === 'string' && f.length > 0);\n}\nif (!areFilesAllStrings(cfg)) {\n  cfg.files = cfg.files.filter((f) => typeof f === 'string' && f.trim());\n}","typeGuard":"/** True when every files entry is a non-empty string. */\nfunction isNonEmptyStringArray(value) {\n  return Array.isArray(value)\n    && value.every((v) => typeof v === 'string' && v.length > 0);\n}","tryCatchPattern":"try {\n  validateConfig(cfg);\n} catch (err) {\n  if (/config\\.files must contain only non-empty strings/.test(err.message)) {\n    cfg.files = cfg.files.filter((f) => typeof f === 'string' && f);\n    validateConfig(cfg); // retry once\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["live-inject","config","validation","json"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}