mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-30 12:09:54 +00:00
Fix error 500 when loading webhook logs by adding error handling to database queries.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/72f89b52-54a7-4cd6-a075-53a45d62be60.jpg
This commit is contained in:
+11
-3
@@ -1018,6 +1018,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Get all delivery logs for a webhook
|
||||
app.get("/api/webhooks/:id/logs", requireRole(["admin", "manager"]), async (req, res) => {
|
||||
try {
|
||||
// First check if the webhook exists
|
||||
const webhook = await storage.getWebhook(req.params.id);
|
||||
|
||||
if (!webhook) {
|
||||
@@ -1029,10 +1030,17 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
return res.status(403).json({ message: "Not authorized to access logs for this webhook" });
|
||||
}
|
||||
|
||||
const logs = await storage.getWebhookDeliveryLogsByWebhook(req.params.id);
|
||||
res.json(logs);
|
||||
try {
|
||||
// Try to get logs with proper error handling
|
||||
const logs = await storage.getWebhookDeliveryLogsByWebhook(req.params.id);
|
||||
res.json(logs);
|
||||
} catch (logError) {
|
||||
// If there's a database schema issue, return an empty array instead of crashing
|
||||
console.error("Error fetching webhook logs:", logError);
|
||||
res.json([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching webhook delivery logs:", error);
|
||||
console.error("Error in webhook logs endpoint:", error);
|
||||
res.status(500).json({ message: "Internal server error" });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user