mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve task update data handling and error logging
Refactors task update logic in server/routes.ts to correctly handle undefined and empty string values, and enhances error logging by including task ID, error details, and request body. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cc2d271b-82f0-4d6a-9302-a0b067ffb429 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cc2d271b-82f0-4d6a-9302-a0b067ffb429/grlWN1D
This commit is contained in:
1 parent
a2eecfb2ac
commit
54c637b7b6
2 files changed
+24
-11
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
+24
-11
@@ -1456,15 +1456,20 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
|
||||
// Nettoyer les données reçues pour éviter les problèmes de types
|
||||
const cleanData = {
|
||||
...(req.body.title && { title: req.body.title }),
|
||||
...(req.body.description !== undefined && { description: req.body.description }),
|
||||
...(req.body.priority && { priority: req.body.priority }),
|
||||
...(req.body.status && { status: req.body.status }),
|
||||
...(req.body.assignedTo && { assignedTo: req.body.assignedTo }),
|
||||
...(req.body.startDate !== undefined && { startDate: req.body.startDate === '' ? null : req.body.startDate }),
|
||||
...(req.body.dueDate !== undefined && { dueDate: req.body.dueDate === '' ? null : req.body.dueDate }),
|
||||
};
|
||||
const cleanData: any = {};
|
||||
|
||||
// Ne pas utiliser de conditions qui ignorent les valeurs falsy légitimes
|
||||
if (req.body.title !== undefined) cleanData.title = req.body.title;
|
||||
if (req.body.description !== undefined) cleanData.description = req.body.description;
|
||||
if (req.body.priority !== undefined) cleanData.priority = req.body.priority;
|
||||
if (req.body.status !== undefined) cleanData.status = req.body.status;
|
||||
if (req.body.assignedTo !== undefined) cleanData.assignedTo = req.body.assignedTo;
|
||||
if (req.body.startDate !== undefined) {
|
||||
cleanData.startDate = req.body.startDate === '' ? null : req.body.startDate;
|
||||
}
|
||||
if (req.body.dueDate !== undefined) {
|
||||
cleanData.dueDate = req.body.dueDate === '' ? null : req.body.dueDate;
|
||||
}
|
||||
|
||||
console.log('🧹 Cleaned data for update:', cleanData);
|
||||
|
||||
@@ -1477,8 +1482,16 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
});
|
||||
res.json(updatedTask);
|
||||
} catch (error) {
|
||||
console.error("Error updating task:", error);
|
||||
res.status(500).json({ message: "Failed to update task" });
|
||||
console.error("❌ Error updating task:", {
|
||||
taskId: id,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
stack: error instanceof Error ? error.stack : undefined,
|
||||
reqBody: req.body
|
||||
});
|
||||
res.status(500).json({
|
||||
message: "Failed to update task",
|
||||
details: error instanceof Error ? error.message : String(error)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user