Skip to content

Commit 88560c6

Browse files
committed
feat: add error handling for SQL validation in dbtIntegration
1 parent ff558a8 commit 88560c6

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/dbt_client/dbtIntegration.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,24 @@ export async function validateSQLUsingSqlGlot(
639639
dialect: string,
640640
models: any,
641641
): Promise<ValidateSqlParseErrorResponse> {
642-
const result = await python?.lock<ValidateSqlParseErrorResponse>(
643-
(python) => python!`to_dict(validate_sql(${query}, ${dialect}, ${models}))`,
644-
);
645-
return result!;
642+
if (!python) {
643+
throw new Error("Python bridge is not available for SQL validation");
644+
}
645+
646+
try {
647+
const result = await python.lock<ValidateSqlParseErrorResponse>(
648+
(python) =>
649+
python!`to_dict(validate_sql(${query}, ${dialect}, ${models}))`,
650+
);
651+
652+
if (!result) {
653+
throw new Error("SQL validation returned no result");
654+
}
655+
656+
return result;
657+
} catch (error) {
658+
throw new Error(
659+
`SQL validation failed: ${error instanceof Error ? error.message : String(error)}`,
660+
);
661+
}
646662
}

0 commit comments

Comments
 (0)