From b7deb5c852c0893a04b78dc36d13ff485ec9fb4f Mon Sep 17 00:00:00 2001 From: Z User Date: Thu, 29 Oct 2026 12:01:05 +0000 Subject: [PATCH] debug: add error body to saveEnvironment for debugging Dokploy 400 --- src/lib/dokploy.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/lib/dokploy.ts b/src/lib/dokploy.ts index ab07812..ce9c5e5 100644 --- a/src/lib/dokploy.ts +++ b/src/lib/dokploy.ts @@ -191,13 +191,26 @@ export function createDokployClient(config: DokployConfig) { const envString = Object.entries(envVars) .map(([key, value]) => `${key}=${value}`) .join('\n') - await call('/application.saveEnvironment', { - applicationId, - env: envString, - buildArgs: '[]', - buildSecrets: '[]', - createEnvFile: true, - }) + try { + await call('/application.saveEnvironment', { + applicationId, + env: envString, + buildArgs: '[]', + buildSecrets: '[]', + createEnvFile: true, + }) + } catch (e) { + // Re-throw with the actual error body for debugging + if (e instanceof DokployError) { + throw new DokployError( + `saveEnvironment failed: ${e.message} | body: ${JSON.stringify(e.body)?.substring(0, 300)}`, + e.status, + '/application.saveEnvironment', + e.body + ) + } + throw e + } } async function deployApplication(applicationId: string): Promise<{ jobId?: string; status: string }> {