musistudio/claude-code-router · error · Error
project_id and path are required to write a Claude Design fi
Error message
project_id and path are required to write a Claude Design file.
What it means
Validation error from upsertProjectFile when normalizing the (projectId, filePath) pair yields an empty project id or path. The write goes through normalizeProjectFileAddress, so inputs that reduce to empty strings fail before the SQLite INSERT OR REPLACE.
Source
Thrown at packages/electron/bundled-plugins/claude-design/index.cjs:9007
}
return queryRows(
runtime.store.database,
"SELECT project_id, path, created_at, updated_at, content_type, body_base64, version FROM claude_design_files WHERE project_id = ? AND path = ? LIMIT 1",
[normalizedProjectId, normalizedPath]
)[0];
}
function getProjectFileText(runtime, projectId, filePath) {
const row = getProjectFileRow(runtime, projectId, filePath);
return row ? Buffer.from(row.body_base64 || "", "base64").toString("utf8") : "";
}
function upsertProjectFile(runtime, projectId, filePath, body, contentType) {
const address = normalizeProjectFileAddress(runtime, projectId, filePath || "");
const normalizedProjectId = address.projectId;
const normalizedPath = address.path;
if (!normalizedProjectId || !normalizedPath) {
throw new Error("project_id and path are required to write a Claude Design file.");
}
const now = new Date().toISOString();
const existing = getProjectFileRow(runtime, normalizedProjectId, normalizedPath);
const version = existing ? Number(existing.version || 0) + 1 : 1;
runtime.store.database.run(
"INSERT OR REPLACE INTO claude_design_files (project_id, path, created_at, updated_at, content_type, body_base64, version) VALUES (?, ?, ?, ?, ?, ?, ?)",
[
normalizedProjectId,
normalizedPath,
existing?.created_at || now,
now,
contentType || guessContentType(normalizedPath),
Buffer.isBuffer(body) ? body.toString("base64") : Buffer.from(String(body || ""), "utf8").toString("base64"),
version
]
);
return getProjectFileRow(runtime, normalizedProjectId, normalizedPath);
}View on GitHub (pinned to 99f24806c6)
Solutions
- Ensure project_id is a non-empty valid id from project creation
- Ensure path is a non-empty relative file path (e.g. designs/home.json)
- Validate/trim inputs in the caller before invoking the API
- Log the normalized address to catch separator/format bugs
Example fix
// before
await upsertProjectFile(runtime, '', '', body, 'application/json');
// after
if (!projectId || !filePath?.trim()) throw new TypeError('projectId and filePath are required');
await upsertProjectFile(runtime, projectId, filePath.trim(), body, 'application/json'); Defensive patterns
Strategy: validation
Validate before calling
if (!String(projectId ?? '').trim() || !String(filePath ?? '').trim()) {
throw new TypeError('projectId and filePath must be non-empty');
} Type guard
function isValidFileAddress(projectId: unknown, filePath: unknown): projectId is string {
return typeof projectId === 'string' && projectId.trim() !== ''
&& typeof filePath === 'string' && filePath.trim() !== '';
} Try / catch
catch (e) { if (/project_id and path are required/.test(e.message)) return { ok: false, error: 'invalid_input' }; throw e; } Prevention
- Require and trim both fields in UI forms
- Validate address format before normalizeProjectFileAddress
- Add JSON-schema validation at the API boundary
When it happens
Trigger: Calling the write-file API with missing project_id, missing/empty path, whitespace-only path, or an address string that normalizes to an empty path segment.
Common situations: UI form submitted without selecting a project, path trimmed to empty, caller passing a directory address instead of a file path, or constructing the address string with a bad separator.
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
- ${message}
- QR window sessionId is required.
- The CCR artifact endpoint returned a non-media content type.
- The CCR media artifact exceeds the inline preview size limit
- Compressed CCR media artifacts are not accepted for inline p
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/240c8f4260514ec8.
Report an issue: GitHub.