From 06c94a1944f240e8ed10cffbf7a8e70929f50de2 Mon Sep 17 00:00:00 2001 From: gnzjgo Date: Mon, 23 Mar 2026 16:06:23 +0100 Subject: [PATCH] fix: show meaningful error messages instead of undefined on build/dev failures (#131) Co-authored-by: Amp Amp-Thread-ID: https://ampcode.com/threads/T-019d1b0d-6dca-7013-a8f8-af75363aae7d --- src/api/build.ts | 4 ++-- src/cli/index.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/api/build.ts b/src/api/build.ts index ecf5939..f2979ec 100644 --- a/src/api/build.ts +++ b/src/api/build.ts @@ -218,12 +218,12 @@ export async function buildToTinybird( ); } - // Helper to format errors + // Helper to format errors - always returns a meaningful string const formatErrors = (): string => { if (body.errors && body.errors.length > 0) { return body.errors.map(e => { const prefix = e.filename ? `[${e.filename}] ` : ''; - return `${prefix}${e.error}`; + return `${prefix}${e.error ?? 'Unknown error'}`; }).join('\n'); } return body.error || `HTTP ${response.status}: ${response.statusText}`; diff --git a/src/cli/index.ts b/src/cli/index.ts index 368fef8..191b444 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -539,8 +539,9 @@ function createCli(): Command { // Show detailed errors if available if (deploy?.errors && deploy.errors.length > 0) { output.showBuildErrors(deploy.errors); - } else if (result.error) { - output.error(result.error); + } else { + const errorMessage = result.error ?? deploy?.error; + output.error(errorMessage ?? "Deploy failed (run with TINYBIRD_DEBUG=1 for more info)"); } output.showDeployFailure(); process.exit(1); @@ -730,8 +731,9 @@ function createCli(): Command { const { deploy } = result; if (deploy?.errors && deploy.errors.length > 0) { output.showBuildErrors(deploy.errors); - } else if (result.error) { - output.error(result.error); + } else { + const errorMessage = result.error ?? deploy?.error; + output.error(errorMessage ?? "Build failed (run with TINYBIRD_DEBUG=1 for more info)"); } output.showBuildFailure(true); return;