fix: convert archivedAt string to Date before Drizzle update

The zod schema validates archivedAt as a datetime string, but Drizzle's
timestamp column expects a Date object. The string was passed directly to
db.update(), causing a 500 error. Now we convert the string to a Date
in the route handler before calling the service.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dotta
2026-03-16 19:48:04 -05:00
parent fee3df2e62
commit bba36ab4c0

View File

@@ -116,7 +116,11 @@ export function projectRoutes(db: Db) {
return;
}
assertCompanyAccess(req, existing.companyId);
const project = await svc.update(id, req.body);
const body = { ...req.body };
if (typeof body.archivedAt === "string") {
body.archivedAt = new Date(body.archivedAt);
}
const project = await svc.update(id, body);
if (!project) {
res.status(404).json({ error: "Project not found" });
return;