musistudio/claude-code-router · error · Error

path is required.

Error message

path is required.

What it means

Thrown by recordDesignSyncJsonAsset when sanitizeProjectFilePath(body.path) returns an empty result — i.e. the provided path is empty or is stripped entirely during sanitization. An asset record requires a valid project-relative file path.

Source

Thrown at packages/electron/bundled-plugins/claude-design/index.cjs:1283

  const paths = Array.isArray(body?.paths) ? body.paths : [];
  let deleted = 0;
  for (const filePath of paths) {
    deleted += deleteProjectFileByPath(runtime, projectId, filePath);
  }
  runtime.store.persist();
  return {
    deleted,
    paths: paths.map((item) => sanitizeProjectFilePath(item)).filter(Boolean),
    projectId,
    project_id: projectId
  };
}

function recordDesignSyncJsonAsset(runtime, body) {
  const projectId = designSyncJsonProjectId(body);
  const filePath = sanitizeProjectFilePath(body?.path || "");
  if (!filePath) {
    throw new Error("path is required.");
  }
  const name = stringValue(body?.name) || filePath;
  const uuid = assetUuid(projectId, name, filePath);
  const asset = {
    chat_id: stringValue(body?.chatId) || stringValue(body?.chat_id) || "",
    name,
    path: filePath,
    project_id: projectId,
    section: stringValue(body?.section) || stringValue(body?.group) || "",
    status: stringValue(body?.status) || "recorded",
    subtitle: stringValue(body?.subtitle) || "",
    uuid,
    viewport: isRecord(body?.viewport) ? body.viewport : undefined
  };
  upsertGenericRecord(runtime.store, "assets", uuid, name, runtime.me.defaultModelId, asset);
  return {
    asset,
    ok: true,

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Provide a non-empty relative path like "assets/icon.png"
  2. Avoid absolute paths and traversal segments; use project-relative paths
  3. Default the path from the asset name when the caller has none: path || `${name}.svg`

Example fix

// before
{ projectId: "proj_123", path: "", name: "hero" }

// after
{ projectId: "proj_123", path: "assets/hero.png", name: "hero" }
Defensive patterns

Strategy: validation

Validate before calling

if (!body?.path || sanitize(body.path) === "") body.path = `${body?.name || "asset"}.svg`;

Type guard

function hasNonEmptySanitizedPath(path: unknown): path is string {
  return typeof path === "string" && path.trim() !== "" && !/^\.{0,2}$/.test(path.trim());
}

Try / catch

try { recordDesignSyncJsonAsset(runtime, body); } catch (e) { if (e instanceof Error && e.message === "path is required.") return respond(400, e.message); throw e; }

Prevention

When it happens

Trigger: Calling the asset endpoint with path omitted, set to "", ".", "/", or a value that sanitization reduces to empty (e.g. only traversal segments like "../..").

Common situations: Client derives the path from a filename variable that is undefined; user saved an asset before choosing a location; aggressive path sanitization stripping leading slashes or dot segments leaving nothing.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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