{"record":{"id":"1d3ff6d67ac94cdb","repo":"Egonex-AI/Understand-Anything","slug":"invalid-input-every-files-entry-must-contain-a-no","errorCode":null,"errorMessage":"Invalid input: every files entry must contain a non-empty path","messagePattern":"Invalid input: every files entry must contain a non-empty path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/extract-import-map.mjs","lineNumber":120,"sourceCode":"  const separators = process.platform === 'win32' ? /[\\\\/]/ : /\\//;\n  return p.split(separators).filter(Boolean).join('/');\n}\n\n/**\n * Validate and normalize the optional selective-analysis path list. Keeping\n * this strict prevents an incremental caller from accidentally asking the\n * extractor to read outside projectRoot or silently miss a typo.\n */\nfunction selectAnalysisFiles(files, analysisPaths) {\n  if (analysisPaths === undefined) return files;\n  if (!Array.isArray(analysisPaths)) {\n    throw new Error('Invalid input: analysisPaths must be an array when provided');\n  }\n\n  const filesByPath = new Map();\n  for (const file of files) {\n    if (!file || typeof file.path !== 'string' || file.path.length === 0) {\n      throw new Error('Invalid input: every files entry must contain a non-empty path');\n    }\n    filesByPath.set(toPosix(file.path), file);\n  }\n\n  const selected = [];\n  const seen = new Set();\n  for (const rawPath of analysisPaths) {\n    if (typeof rawPath !== 'string' || rawPath.length === 0) {\n      throw new Error('Invalid input: every analysisPaths entry must be a non-empty string');\n    }\n    // Use the host's path semantics here. On POSIX, backslashes and drive-like\n    // prefixes are ordinary project-relative filename characters; on Windows,\n    // path.isAbsolute also rejects drive-rooted and root-relative paths.\n    if (isAbsolute(rawPath)) {\n      throw new Error(`Invalid input: analysisPaths entry must be project-relative: ${rawPath}`);\n    }\n    const path = toPosix(rawPath);\n    if (!path || path.split('/').some(part => part === '..')) {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/extract-import-map.mjs#L102-L138","documentation":"selectAnalysisFiles builds an internal path-keyed map from the `files` argument, requiring every entry to be an object with a non-empty string `path`. A malformed entry (null, a bare string, or an object whose path is empty/undefined) would make the selection map unreliable, so the extractor throws this error immediately.","triggerScenarios":"Calling selectAnalysisFiles with a `files` array containing null/undefined elements, plain string paths instead of `{ path: string }` objects, or entries where `path` is empty string after an upstream filter; also when a files producer emits `{file: ...}` instead of `{path: ...}`.","commonSituations":"An upstream discovery script maps paths to objects but one glob resolves to nothing and nulls leak in; a caller reuses a different module's file record shape (`{ name }` or `{ filePath }`); empty-string paths from filtering out non-project files without removing the entry.","solutions":["Normalize entries to `{ path: \"<project-relative string>\" }` before calling — map bare strings via `p => ({ path: p })`.","Filter falsy entries: `files.filter(Boolean)` and drop entries with empty paths before invocation.","Rename mismatched keys at the boundary: `files.map(f => ({ path: f.filePath ?? f.name }))`.","Validate with `files.every(f => f && typeof f.path === 'string' && f.path.length > 0)` in the producer."],"exampleFix":"// before\nselectAnalysisFiles([\"src/a.ts\", null], analysisPaths);\n\n// after\nselectAnalysisFiles([{ path: \"src/a.ts\" }].filter(f => f && f.path), analysisPaths);","handlingStrategy":"validation","validationCode":"const validFiles = files\n  .filter(Boolean)\n  .map(f => (typeof f === 'string' ? { path: f } : f))\n  .filter(f => typeof f.path === 'string' && f.path.length > 0);","typeGuard":"function isFileEntry(f) {\n  return typeof f === 'object' && f !== null && typeof f.path === 'string' && f.path.length > 0;\n}","tryCatchPattern":"try {\n  selectAnalysisFiles(files, analysisPaths);\n} catch (err) {\n  if (err.message.includes('every files entry')) {\n    console.error('files must be [{ path: string }, ...]; sanitize with filter(Boolean) and string-to-object mapping');\n  } else {\n    throw err;\n  }\n}","preventionTips":["Sanitize the files array at the producer boundary (drop nulls, map bare strings to { path }).","Standardize on the `{ path }` field name across all pipeline file records.","Never emit entries for globs that resolved to nothing — skip instead of pushing null.","Validate the array once after discovery, before any consumer runs."],"tags":["validation","input-shape","import-map"],"backgroundTag":"invalid-argument-value","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}