Skip to content

Commit 2f3b7ea

Browse files
committed
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 <mary.akowe@madetech.com>
1 parent 444c50d commit 2f3b7ea

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

sqlmesh/integrations/dlt.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ def generate_incremental_model(
214214

215215
def format_config(configs: t.Dict[str, str], db_type: str) -> str:
216216
"""Generate a string for the gateway connection config."""
217-
config = {
218-
"type": db_type,
219-
}
217+
config: t.Dict[str, t.Any] = {}
220218

221219
for key, value in configs.items():
222220
if key == "password":
@@ -226,6 +224,11 @@ def format_config(configs: t.Dict[str, str], db_type: str) -> str:
226224
else:
227225
config[key] = value
228226

227+
# Set db_type after iterating credentials so that credential attributes
228+
# with a conflicting name (e.g. GCP service-account JSON contains
229+
# "type": "service_account") cannot overwrite the connection type.
230+
config["type"] = db_type
231+
229232
# Validate the connection config fields
230233
invalid_fields = []
231234
try:

0 commit comments

Comments
 (0)