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:
@@ -116,7 +116,11 @@ export function projectRoutes(db: Db) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assertCompanyAccess(req, existing.companyId);
|
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) {
|
if (!project) {
|
||||||
res.status(404).json({ error: "Project not found" });
|
res.status(404).json({ error: "Project not found" });
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user