{"record":{"id":"66fe8f5d11265ea6","repo":"pbakaus/impeccable","slug":"config-files-non-empty-string-array-required-66fe8f","errorCode":null,"errorMessage":"config.files (non-empty string array) required","messagePattern":"config\\.files \\(non-empty string array\\) required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skill/scripts/live-inject.mjs","lineNumber":452,"sourceCode":"    } else if (/[.+^${}()|[\\]\\\\]/.test(c)) {\n      re += '\\\\' + c;\n      i += 1;\n    } 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  }","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/skill/scripts/live-inject.mjs#L434-L470","documentation":"Thrown by validateConfig() when cfg.files is missing, not an array, or an empty array. The files array is the set of source files live-inject will modify, so it is mandatory and non-empty — without it there is nothing to inject into.","triggerScenarios":"A config.json with no `files` key, with `files: {}`, or with `files: []`. Also a programmatic cfg object omitting the field.","commonSituations":"Skeleton config copied without filling in files; a glob expansion that produced zero matches being written verbatim; renaming the key (e.g. to `targets`).","solutions":["Add a non-empty `files` array of source paths, e.g. \"files\": [\"src/app.tsx\", \"src/pages/*.astro\"].","Confirm each entry is a non-empty string (a follow-up check enforces this).","Verify the glob/path actually resolves to at least one file before writing it into config."],"exampleFix":"// before\n{ \"insertAfter\": \"</head>\" }\n// after\n{ \"files\": [\"src/app.tsx\"], \"insertAfter\": \"</head>\" }","handlingStrategy":"validation","validationCode":"if (!Array.isArray(cfg.files) || cfg.files.length === 0) {\n  throw new Error('config.files must be a non-empty string array');\n}","typeGuard":"function hasNonEmptyFiles(cfg) {\n  return Array.isArray(cfg.files) && cfg.files.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always include a non-empty files array in live-inject config.","Confirm the glob resolves to at least one file before writing config."],"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"}