Skip to content

Commit 5ad3fa0

Browse files
samzongsteipete
authored andcommitted
fix(memory): preserve ENOTDIR missing reads
Signed-off-by: samzong <samzong.lu@gmail.com>
1 parent c6748a8 commit 5ad3fa0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/memory-host-sdk/src/host/fs-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ if (!hasPythonModeOverride) {
1818

1919
export function isFileMissingError(
2020
err: unknown,
21-
): err is NodeJS.ErrnoException & { code: "ENOENT" } {
21+
): err is NodeJS.ErrnoException & { code: "ENOENT" | "ENOTDIR" | "not-found" } {
2222
return Boolean(
2323
err &&
2424
typeof err === "object" &&
2525
"code" in err &&
2626
((err as Partial<NodeJS.ErrnoException>).code === "ENOENT" ||
27+
(err as Partial<NodeJS.ErrnoException>).code === "ENOTDIR" ||
2728
(err as { code?: unknown }).code === "not-found"),
2829
);
2930
}

packages/memory-host-sdk/src/host/read-file.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ describe("readMemoryFile", () => {
3737
text: "",
3838
path: path.relative(workspaceDir, missingPath).replace(/\\/g, "/"),
3939
});
40+
41+
const nonDirectoryParentPath = path.join(extraDir, "note.md", "child.md");
42+
await fs.writeFile(path.join(extraDir, "note.md"), "note", "utf-8");
43+
await expect(
44+
readMemoryFile({
45+
workspaceDir,
46+
extraPaths: [extraDir],
47+
relPath: nonDirectoryParentPath,
48+
}),
49+
).resolves.toEqual({
50+
text: "",
51+
path: path.relative(workspaceDir, nonDirectoryParentPath).replace(/\\/g, "/"),
52+
});
4053
} finally {
4154
await fs.rm(tmpRoot, { recursive: true, force: true });
4255
}

0 commit comments

Comments
 (0)