Egonex-AI/Understand-Anything · error

Invalid input: every analysisPaths entry must be a non-empty

Error message

Invalid input: every analysisPaths entry must be a non-empty string

What it means

Each entry in `analysisPaths` must be a non-empty, project-relative string. Empty or non-string entries throw this error; absolute paths (per the host's path semantics — drive-rooted/root-relative on Windows, leading '/' on POSIX) throw the related 'must be project-relative' error, since the strict rule prevents the extractor from reading outside projectRoot or silently missing a typo in an incremental run.

Source

Thrown at understand-anything-plugin/skills/understand/extract-import-map.mjs:129

function selectAnalysisFiles(files, analysisPaths) {
  if (analysisPaths === undefined) return files;
  if (!Array.isArray(analysisPaths)) {
    throw new Error('Invalid input: analysisPaths must be an array when provided');
  }

  const filesByPath = new Map();
  for (const file of files) {
    if (!file || typeof file.path !== 'string' || file.path.length === 0) {
      throw new Error('Invalid input: every files entry must contain a non-empty path');
    }
    filesByPath.set(toPosix(file.path), file);
  }

  const selected = [];
  const seen = new Set();
  for (const rawPath of analysisPaths) {
    if (typeof rawPath !== 'string' || rawPath.length === 0) {
      throw new Error('Invalid input: every analysisPaths entry must be a non-empty string');
    }
    // Use the host's path semantics here. On POSIX, backslashes and drive-like
    // prefixes are ordinary project-relative filename characters; on Windows,
    // path.isAbsolute also rejects drive-rooted and root-relative paths.
    if (isAbsolute(rawPath)) {
      throw new Error(`Invalid input: analysisPaths entry must be project-relative: ${rawPath}`);
    }
    const path = toPosix(rawPath);
    if (!path || path.split('/').some(part => part === '..')) {
      throw new Error(`Invalid input: analysisPaths entry escapes projectRoot: ${rawPath}`);
    }
    const file = filesByPath.get(path);
    if (!file) {
      throw new Error(`Invalid input: analysisPaths entry is not present in files: ${rawPath}`);
    }
    if (!seen.has(path)) {
      seen.add(path);
      selected.push(file);

View on GitHub (pinned to 07edf82a04)

Solutions

  1. Convert entries to project-relative: strip the projectRoot prefix (`path.relative(projectRoot, abs)`), and normalize to POSIX separators.
  2. Filter empties after splitting: `value.split(',').filter(Boolean)`.
  3. Ensure every entry is a non-empty string before calling; coerce or reject non-strings upstream.
  4. On Windows, avoid drive-rooted or root-relative entries — the extractor deliberately rejects them with path.isAbsolute.

Example fix

// before
selectAnalysisFiles(files, ["/abs/repo/src/a.ts", ""]);

// after
import path from 'node:path';
const rel = ["/abs/repo/src/a.ts"].map(p => path.relative(projectRoot, p)).filter(Boolean);
selectAnalysisFiles(files, rel);
Defensive patterns

Strategy: validation

Validate before calling

import path from 'node:path';
function toRelativeAnalysisPaths(entries, projectRoot) {
  return entries
    .filter(e => typeof e === 'string' && e.length > 0)
    .map(e => path.isAbsolute(e) ? path.relative(projectRoot, e) : e)
    .filter(e => e.length > 0 && !e.startsWith('..'));
}

Type guard

function isProjectRelativePath(p) {
  return typeof p === 'string' && p.length > 0 && !path.isAbsolute(p) && !p.split(/[\\/]/).includes('..');
}

Try / catch

try {
  selectAnalysisFiles(files, analysisPaths);
} catch (err) {
  if (err.message.includes('analysisPaths entry')) {
    console.error('analysisPaths entries must be non-empty project-relative strings:', err.message);
    // convert absolute paths via path.relative(projectRoot, entry) and retry
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Calling selectAnalysisFiles with `analysisPaths: [""]`, entries that are null/numbers after a bad split (e.g. "a,,b".split(',')), or absolute paths like "/src/a.ts" or "C:\\src\\a.ts" (the latter trips the sibling project-relative error).

Common situations: Trailing commas in a hand-edited config produce empty strings from split(); a caller passes absolute paths from an editor API instead of project-relative ones; Windows users paste paths with drive letters; a diff tool emits absolute repo paths while the extractor expects root-relative.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of Egonex-AI/Understand-Anything@07edf82a04 (2026-09-07). Data as JSON: /api/errors/9a923a497f29d921. Report an issue: GitHub.