From bd3917e2f327c5b6ea386b56c9db65fb3e391823 Mon Sep 17 00:00:00 2001 From: neatninja Date: Sun, 27 Sep 2026 09:00:51 +0530 Subject: [PATCH] fix(config): parse default_test_connection from yaml The connection validator was registered for the alias default_test_connection, but field_validator matches field names, so the default_test_connection_ field never got it. A YAML mapping was validated against the abstract ConnectionConfig and rejected. Signed-off-by: neatninja --- sqlmesh/core/config/connection.py | 3 ++- tests/core/test_config.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sqlmesh/core/config/connection.py b/sqlmesh/core/config/connection.py index 73fe1b9300..5fe937a4aa 100644 --- a/sqlmesh/core/config/connection.py +++ b/sqlmesh/core/config/connection.py @@ -2657,7 +2657,8 @@ def _connection_config_validator( "state_connection", "test_connection", "default_connection", - "default_test_connection", + # field_validator matches field names, not aliases + "default_test_connection_", mode="before", check_fields=False, )(_connection_config_validator) diff --git a/tests/core/test_config.py b/tests/core/test_config.py index 0da5b6e22f..12f461913a 100644 --- a/tests/core/test_config.py +++ b/tests/core/test_config.py @@ -553,6 +553,30 @@ def test_connection_config_serialization(): } +def test_default_test_connection_from_yaml(tmp_path): + config_path = tmp_path / "config.yaml" + config_path.write_text( + """ +default_test_connection: + type: duckdb + database: test.db + concurrent_tasks: 4 + +model_defaults: + dialect: duckdb +""" + ) + + config = load_config_from_paths(Config, project_paths=[config_path]) + + assert config.default_test_connection_ == DuckDBConnectionConfig( + database="test.db", concurrent_tasks=4 + ) + assert config.get_test_connection() == DuckDBConnectionConfig( + database="test.db", concurrent_tasks=4 + ) + + def test_variables(): variables = { "int_var": 1,