From: Stefan Gasser Date: Fri, 9 Jan 2026 07:28:55 +0000 (+0100) Subject: Fix EISDIR error when config.yaml is a directory (#3) X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=2a19bbecb823f0651a59d77a846f2e51ae4a1c28;p=sgasser-llm-shield.git Fix EISDIR error when config.yaml is a directory (#3) Add isFile() check before reading config to give a clear error message when Docker creates a directory instead of mounting a missing file. Fixes #2 --- diff --git a/src/config.ts b/src/config.ts index 318d6ae..a5bc8fc 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ -import { existsSync, readFileSync } from "node:fs"; +import { existsSync, readFileSync, statSync } from "node:fs"; import { parse as parseYaml } from "yaml"; import { z } from "zod"; @@ -181,6 +181,11 @@ export function loadConfig(configPath?: string): Config { for (const path of paths) { if (existsSync(path)) { + if (!statSync(path).isFile()) { + throw new Error( + `'${path}' is a directory, not a file. Run: cp config.example.yaml config.yaml`, + ); + } configFile = readFileSync(path, "utf-8"); break; }