Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20251201-165209.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Raise jsonschema-based deprecation warnings by default
time: 2025-12-01T16:52:09.354436-05:00
custom:
Author: michelleark
Issue: 12240
4 changes: 0 additions & 4 deletions core/dbt/jsonschemas/jsonschemas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os
import re
from datetime import date, datetime
from pathlib import Path
Expand Down Expand Up @@ -141,9 +140,6 @@ def _get_allowed_config_fields_from_error_path(


def _can_run_validations() -> bool:
if not os.environ.get("DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS"):
return False

invocation_context = get_invocation_context()
return invocation_context.adapter_types.issubset(_JSONSCHEMA_SUPPORTED_ADAPTERS)

Expand Down
16 changes: 0 additions & 16 deletions tests/functional/deprecations/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ def models(self):
"models.yml": invalid_deprecation_date_yaml,
}

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_deprecated_invalid_deprecation_date(self, project):
event_catcher = EventCatcher(GenericJSONSchemaValidationDeprecation)
note_catcher = EventCatcher(Note)
Expand Down Expand Up @@ -362,7 +361,6 @@ def models(self):
}

@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_custom_key_in_config_deprecation(self, project):
event_catcher = EventCatcher(CustomKeyInConfigDeprecation)
run_dbt(
Expand All @@ -384,7 +382,6 @@ def models(self):
}

@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_custom_key_in_config_sql_deprecation(self, project):
event_catcher = EventCatcher(CustomKeyInConfigDeprecation)
run_dbt(
Expand Down Expand Up @@ -415,7 +412,6 @@ def models(self):
}

@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_multiple_custom_keys_in_config_deprecation(self, project):
event_catcher = EventCatcher(CustomKeyInConfigDeprecation)
run_dbt(
Expand All @@ -442,7 +438,6 @@ def models(self):
}

@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_custom_key_in_object_deprecation(self, project):
event_catcher = EventCatcher(CustomKeyInObjectDeprecation)
run_dbt(["parse", "--no-partial-parse"], callbacks=[event_catcher.catch])
Expand Down Expand Up @@ -486,7 +481,6 @@ def test_jsonschema_validation_deprecations_arent_run_without_env_var(


class TestHappyPathProjectHasNoDeprecations:
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_happy_path_project_has_no_deprecations(self, happy_path_project):
event_cathcer = EventCatcher(DeprecationsSummary)
Expand All @@ -498,7 +492,6 @@ def test_happy_path_project_has_no_deprecations(self, happy_path_project):


class TestBaseProjectHasNoDeprecations:
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_base_project_has_no_deprecations(self, project):
event_cathcer = EventCatcher(DeprecationsSummary)
Expand Down Expand Up @@ -707,7 +700,6 @@ class TestMissingPlusPrefixDeprecation:
def project_config_update(self):
return {"seeds": {"path": {"enabled": True}}}

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_missing_plus_prefix_deprecation(self, project):
event_catcher = EventCatcher(MissingPlusPrefixDeprecation)
Expand All @@ -721,7 +713,6 @@ class TestMissingPlusPrefixDeprecationSubPath:
def project_config_update(self):
return {"seeds": {"path": {"+enabled": True, "sub_path": {"enabled": True}}}}

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_missing_plus_prefix_deprecation_sub_path(self, project):
event_catcher = EventCatcher(MissingPlusPrefixDeprecation)
Expand All @@ -735,7 +726,6 @@ class TestMissingPlusPrefixDeprecationCustomConfig:
def project_config_update(self):
return {"seeds": {"path": {"custom_config": True, "sub_path": {"+enabled": True}}}}

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_missing_plus_prefix_deprecation_sub_path(self, project):
event_catcher = EventCatcher(MissingPlusPrefixDeprecation)
Expand All @@ -749,7 +739,6 @@ class TestCustomConfigInDbtProjectYmlNoDeprecation:
def project_config_update(self):
return {"seeds": {"path": {"+custom_config": True}}}

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_missing_plus_prefix_deprecation_sub_path(self, project):
note_catcher = EventCatcher(Note)
Expand Down Expand Up @@ -782,10 +771,6 @@ def test_jsonschema_validation_gating(
dbt_private_run_jsonschema_validations: bool,
expected_events: int,
) -> None:
mocker.patch.dict(
os.environ,
{"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": dbt_private_run_jsonschema_validations},
)

if postgres_is_valid:
supported_adapters_with_postgres = {
Expand Down Expand Up @@ -911,7 +896,6 @@ def models(self):
"models.yml": property_moved_to_config_yaml,
}

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
def test_property_moved_to_config_deprecation(self, project):
event_catcher = EventCatcher(PropertyMovedToConfigDeprecation)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from datetime import datetime, timedelta, timezone
from unittest import mock

Expand Down Expand Up @@ -99,7 +98,6 @@ def _set_updated_at_to(self, insert_id, delta, project):
return insert_id + 1

@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_source_overrides(self, project):
insert_id = 101

Expand Down
2 changes: 0 additions & 2 deletions tests/functional/test_project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from unittest import mock

import yaml
Expand Down Expand Up @@ -28,7 +27,6 @@ def test_project(self, project, mocker: MockerFixture) -> None:
class TestGenericJsonSchemaValidationDeprecation:
"""Ensure that the generic jsonschema validation deprecation can be fired"""

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_project(self, project, project_root: str) -> None:

# `name` was already required prior to this deprecation, so this deprecation doesn't
Expand Down
1 change: 0 additions & 1 deletion tests/unit/config/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ def test_impossible_version_range(self, project_dict: Dict[str, Any]) -> None:

class TestDeprecations:

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_jsonschema_validate(self) -> None:
from dbt.jsonschemas.jsonschemas import jsonschema_validate

Expand Down
5 changes: 0 additions & 5 deletions tests/unit/test_jsonschemas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import os
from unittest import mock

from dbt.deprecations import (
CustomKeyInConfigDeprecation,
CustomKeyInObjectDeprecation,
Expand All @@ -14,7 +11,6 @@


class TestValidateModelConfigNoError:
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_validate_model_config_no_error(self):
safe_set_invocation_context()
get_invocation_context().uses_adapter("snowflake")
Expand All @@ -27,7 +23,6 @@ def test_validate_model_config_no_error(self):
validate_model_config(config, "test.yml")
assert len(caught_events) == 0

@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
def test_validate_model_config_error(self):
safe_set_invocation_context()
get_invocation_context().uses_adapter("snowflake")
Expand Down
Loading