mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 05:25:18 +00:00
fix(application): improve error handling and notification messages during deployment
This commit is contained in:
@@ -142,11 +142,10 @@ export const updateApplication = async (
|
|||||||
applicationId: string,
|
applicationId: string,
|
||||||
applicationData: Partial<Application>,
|
applicationData: Partial<Application>,
|
||||||
) => {
|
) => {
|
||||||
const { appName, ...rest } = applicationData;
|
|
||||||
const application = await db
|
const application = await db
|
||||||
.update(applications)
|
.update(applications)
|
||||||
.set({
|
.set({
|
||||||
...rest,
|
...applicationData,
|
||||||
})
|
})
|
||||||
.where(eq(applications.applicationId, applicationId))
|
.where(eq(applications.applicationId, applicationId))
|
||||||
.returning();
|
.returning();
|
||||||
@@ -237,12 +236,21 @@ export const deployApplication = async ({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "error");
|
await updateDeploymentStatus(deployment.deploymentId, "error");
|
||||||
await updateApplicationStatus(applicationId, "error");
|
await updateApplicationStatus(applicationId, "error");
|
||||||
|
|
||||||
|
const errorMessage =
|
||||||
|
error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: String(error) || "Error building";
|
||||||
|
// Truncate and sanitize error message for notifications
|
||||||
|
const sanitizedErrorMessage = errorMessage
|
||||||
|
.replace(/ghs_[a-zA-Z0-9]+/g, "ghs_***") // Hide GitHub tokens
|
||||||
|
.substring(0, 1500); // Truncate to avoid notification limits
|
||||||
|
|
||||||
await sendBuildErrorNotifications({
|
await sendBuildErrorNotifications({
|
||||||
projectName: application.project.name,
|
projectName: application.project.name,
|
||||||
applicationName: application.name,
|
applicationName: application.name,
|
||||||
applicationType: "application",
|
applicationType: "application",
|
||||||
// @ts-ignore
|
errorMessage: sanitizedErrorMessage,
|
||||||
errorMessage: error?.message || "Error building",
|
|
||||||
buildLink,
|
buildLink,
|
||||||
organizationId: application.project.organizationId,
|
organizationId: application.project.organizationId,
|
||||||
});
|
});
|
||||||
@@ -370,8 +378,9 @@ export const deployRemoteApplication = async ({
|
|||||||
domains: application.domains,
|
domains: application.domains,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// @ts-ignore
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
const encodedContent = encodeBase64(error?.message);
|
|
||||||
|
const encodedContent = encodeBase64(errorMessage);
|
||||||
|
|
||||||
await execAsyncRemote(
|
await execAsyncRemote(
|
||||||
application.serverId,
|
application.serverId,
|
||||||
@@ -383,12 +392,12 @@ export const deployRemoteApplication = async ({
|
|||||||
|
|
||||||
await updateDeploymentStatus(deployment.deploymentId, "error");
|
await updateDeploymentStatus(deployment.deploymentId, "error");
|
||||||
await updateApplicationStatus(applicationId, "error");
|
await updateApplicationStatus(applicationId, "error");
|
||||||
|
|
||||||
await sendBuildErrorNotifications({
|
await sendBuildErrorNotifications({
|
||||||
projectName: application.project.name,
|
projectName: application.project.name,
|
||||||
applicationName: application.name,
|
applicationName: application.name,
|
||||||
applicationType: "application",
|
applicationType: "application",
|
||||||
// @ts-ignore
|
errorMessage: `Please check the logs for details: ${errorMessage}`,
|
||||||
errorMessage: error?.message || "Error building",
|
|
||||||
buildLink,
|
buildLink,
|
||||||
organizationId: application.project.organizationId,
|
organizationId: application.project.organizationId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ export const sendBuildErrorNotifications = async ({
|
|||||||
const decorate = (decoration: string, text: string) =>
|
const decorate = (decoration: string, text: string) =>
|
||||||
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
`${discord.decoration ? decoration : ""} ${text}`.trim();
|
||||||
|
|
||||||
|
const limitCharacter = 800;
|
||||||
|
const truncatedErrorMessage = errorMessage.substring(0, limitCharacter);
|
||||||
await sendDiscordNotification(discord, {
|
await sendDiscordNotification(discord, {
|
||||||
title: decorate(">", "`⚠️` Build Failed"),
|
title: decorate(">", "`⚠️` Build Failed"),
|
||||||
color: 0xed4245,
|
color: 0xed4245,
|
||||||
@@ -101,7 +103,7 @@ export const sendBuildErrorNotifications = async ({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: decorate("`⚠️`", "Error Message"),
|
name: decorate("`⚠️`", "Error Message"),
|
||||||
value: `\`\`\`${errorMessage}\`\`\``,
|
value: `\`\`\`${truncatedErrorMessage}\`\`\``,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: decorate("`🧷`", "Build Link"),
|
name: decorate("`🧷`", "Build Link"),
|
||||||
|
|||||||
Reference in New Issue
Block a user