Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

fix(ingest): report "Path not found" instead of a bare ENOENT

KageBinary865483d3404e
diff --git a/ix-cli/src/cli/__tests__/ingest-files.test.ts b/ix-cli/src/cli/__tests__/ingest-files.test.ts
index 5d87a977..cf943fbf 100644
--- a/ix-cli/src/cli/__tests__/ingest-files.test.ts
+++ b/ix-cli/src/cli/__tests__/ingest-files.test.ts
@@ -984,6 +984,12 @@ describe("ingestFiles against a fake backend", () => {
expect(baselineFiles().sort(), "the TypeScript files keep their entries").toEqual([...everything].sort());
});
+ it("names a missing path rather than failing with a bare ENOENT", async () => {
+ await expect(
+ ingestFiles(join(repo, "no-such-dir"), { format: "text", suppressOutput: true, printSummary: false }),
+ ).rejects.toThrow(/^Path not found: /);
+ });
+
it("sends workspace-relative uris when the path it is given is a symlink", async () => {
// Discovery canonicalises every file with realpath; the root has to be
// canonical too, or every source_uri comes out as `../<real dir>/src/x.ts`
diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.ts
index bd5069cf..1fd12858 100644
--- a/ix-cli/src/cli/commands/ingest.ts
+++ b/ix-cli/src/cli/commands/ingest.ts
@@ -1522,6 +1522,12 @@ export async function ingestFiles(
const resolvedPath = canonicalWorkspacePath(nodePath.isAbsolute(path)
? path
: nodePath.resolve(resolveWorkspaceRoot(opts.root), path));
+ // Here, not in the discovery phase below: the statSync that picks the
+ // workspace root runs first, and threw a bare ENOENT before the friendly
+ // message there could be reached.
+ if (!fs.existsSync(resolvedPath)) {
+ throw new Error(`Path not found: ${resolvedPath}`);
+ }
// Workspace identity for client-agnostic backend.
//
@@ -1978,9 +1984,6 @@ export async function ingestFiles(
// Phase: discover files
const langFilter = opts.lang ? parseLangs(opts.lang) : null;
- if (!fs.existsSync(resolvedPath)) {
- throw new Error(`Path not found: ${resolvedPath}`);
- }
const stat = fs.statSync(resolvedPath);
const excludePatterns = collectExcludePatterns(resolvedPath, opts.exclude ?? []);
const excludeMatcher = createIgnoreMatcher(excludePatterns);