musistudio/claude-code-router · error · Error

A valid filesystem path is required.

Error message

A valid filesystem path is required.

What it means

Error "A valid filesystem path is required." thrown in musistudio/claude-code-router.

Source

Thrown at packages/core/src/routing/route-script-worker.ts:287

}

async function readTextFile(file: string): Promise<string> {
  const target = resolveScriptPath(file);
  const stat = await fs.stat(target);
  if (!stat.isFile()) throw new Error(`"${file}" is not a file.`);
  if (stat.size > maxFileBytes) throw new Error(`File exceeds ${maxFileBytes} bytes.`);
  return await fs.readFile(target, "utf8");
}

async function writeTextFile(file: string, value: string): Promise<void> {
  if (Buffer.byteLength(value, "utf8") > maxFileBytes) throw new Error(`File exceeds ${maxFileBytes} bytes.`);
  const target = resolveScriptPath(file);
  await fs.writeFile(target, value, "utf8");
}

function resolveScriptPath(file: string): string {
  if (typeof file !== "string" || !file.trim() || file.includes("\0")) {
    throw new Error("A valid filesystem path is required.");
  }
  if (file === "~") return path.resolve(os.homedir());
  if (file.startsWith("~/") || file.startsWith("~\\")) {
    return path.resolve(os.homedir(), file.slice(2));
  }
  return path.resolve(file);
}

function assertHttpUrl(rawUrl: string): void {
  let url: URL;
  try {
    url = new URL(rawUrl);
  } catch {
    throw new Error(`Invalid URL "${rawUrl}".`);
  }
  if ((url.protocol !== "http:" && url.protocol !== "https:") || url.username || url.password || !url.hostname) {
    throw new Error("Only HTTP(S) URLs without embedded credentials are supported.");
  }

View on GitHub (pinned to 99f24806c6)

When it happens

Trigger: Thrown at packages/core/src/routing/route-script-worker.ts:287 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/3fdcd312db06a7e4. Report an issue: GitHub.