From 2f3b7ea4b2aff25a02f697141d948435e47a3de5 Mon Sep 17 00:00:00 2001 From: Mary Akowe Date: Tue, 23 Jun 2026 10:47:32 +0100 Subject: [PATCH 1/2] fix(dlt): prevent credential type field overwriting db_type in format_config format_config initialises config = {"type": db_type} then iterates all credential object attributes and writes them into config. BigQuery service-account credentials carry a "type": "service_account" field (from the GCP service account JSON format) which overwrites the "bigquery" key. parse_connection_config then raises: ConfigError: Unknown connection type 'service_account' This error fires before model generation starts, even though the direct caller (generate_dlt_models) discards the connection config entirely. The bug only surfaces with BigQuery service-account credentials; OAUTH credentials do not carry a conflicting type field. Fix: move config["type"] = db_type to after the credential loop so it cannot be overwritten by credential attributes. Signed-off-by: Mary Akowe --- sqlmesh/integrations/dlt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sqlmesh/integrations/dlt.py b/sqlmesh/integrations/dlt.py index a2202bea02..146c91b661 100644 --- a/sqlmesh/integrations/dlt.py +++ b/sqlmesh/integrations/dlt.py @@ -214,9 +214,7 @@ def generate_incremental_model( def format_config(configs: t.Dict[str, str], db_type: str) -> str: """Generate a string for the gateway connection config.""" - config = { - "type": db_type, - } + config: t.Dict[str, t.Any] = {} for key, value in configs.items(): if key == "password": @@ -226,6 +224,11 @@ def format_config(configs: t.Dict[str, str], db_type: str) -> str: else: config[key] = value + # Set db_type after iterating credentials so that credential attributes + # with a conflicting name (e.g. GCP service-account JSON contains + # "type": "service_account") cannot overwrite the connection type. + config["type"] = db_type + # Validate the connection config fields invalid_fields = [] try: From b927e568d781ef5a4d6ff5e4e667ecad113fcfa0 Mon Sep 17 00:00:00 2001 From: Mary Akowe Date: Tue, 23 Jun 2026 16:57:46 +0100 Subject: [PATCH 2/2] test(dlt): reorder connection fields in test_dlt_pipeline Signed-off-by: Mary Akowe --- tests/cli/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 938f90cc74..eff00a907f 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -1020,8 +1020,8 @@ def test_dlt_pipeline(runner, tmp_path): gateways: duckdb: connection: - type: duckdb database: {dataset_path} + type: duckdb default_gateway: duckdb # --- Model Defaults ---