Skip to content

Commit 64610b9

Browse files
feat: add check_config_during_discover flag for targeted config validation control
Co-Authored-By: Aaron <AJ> Steers <[email protected]>
1 parent 4253f28 commit 64610b9

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Newer updates can be found here: [GitHub Release Notes](https://github.com/airby
44

55
# Changelog
66

7+
## Unreleased
8+
9+
- Added `check_config_during_discover` flag to declarative sources to skip config validation during discovery for sources with DynamicSchemaLoader
10+
711
## 6.5.2
812

913
bugfix: Ensure that streams with partition router are not executed concurrently

airbyte_cdk/entrypoint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def run(self, parsed_args: argparse.Namespace) -> Iterable[str]:
149149
elif (
150150
cmd == "discover"
151151
and not parsed_args.config
152-
and not self.source.check_config_against_spec
152+
and hasattr(self.source, "check_config_during_discover")
153+
and self.source.check_config_during_discover
153154
):
154155
# Connector supports unprivileged discover
155156
empty_config: dict[str, Any] = {}
@@ -240,7 +241,7 @@ def discover(
240241
self, source_spec: ConnectorSpecification, config: TConfig
241242
) -> Iterable[AirbyteMessage]:
242243
self.set_up_secret_filter(config, source_spec.connectionSpecification)
243-
if self.source.check_config_against_spec:
244+
if not hasattr(self.source, "check_config_during_discover") or not self.source.check_config_during_discover:
244245
self.validate_connection(source_spec, config)
245246
catalog = self.source.discover(self.logger, config)
246247

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def __init__(
109109
self._config = config or {}
110110
self._validate_source()
111111

112-
self.check_config_against_spec = not self._uses_dynamic_schema_loader()
112+
self.check_config_during_discover = self._uses_dynamic_schema_loader()
113+
self.check_config_against_spec = True
113114

114115
@property
115116
def resolved_manifest(self) -> Mapping[str, Any]:

unit_tests/sources/declarative/test_manifest_declarative_source_dynamic_schema.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit
1111

1212

13-
def test_check_config_against_spec_with_dynamic_schema_loader():
14-
"""Test that check_config_against_spec is False when DynamicSchemaLoader is used."""
13+
def test_check_config_during_discover_with_dynamic_schema_loader():
14+
"""Test that check_config_during_discover is True when DynamicSchemaLoader is used."""
1515
source_config = {
1616
"type": "DeclarativeSource",
1717
"check": {"type": "CheckStream"},
@@ -41,11 +41,12 @@ def test_check_config_against_spec_with_dynamic_schema_loader():
4141

4242
source = ManifestDeclarativeSource(source_config=source_config)
4343

44-
assert source.check_config_against_spec is False
44+
assert source.check_config_during_discover is True
45+
assert source.check_config_against_spec is True
4546

4647

47-
def test_check_config_against_spec_without_dynamic_schema_loader():
48-
"""Test that check_config_against_spec is True when DynamicSchemaLoader is not used."""
48+
def test_check_config_during_discover_without_dynamic_schema_loader():
49+
"""Test that check_config_during_discover is False when DynamicSchemaLoader is not used."""
4950
source_config = {
5051
"type": "DeclarativeSource",
5152
"check": {"type": "CheckStream"},
@@ -64,6 +65,9 @@ def test_check_config_against_spec_without_dynamic_schema_loader():
6465
}
6566

6667
source = ManifestDeclarativeSource(source_config=source_config)
68+
69+
assert source.check_config_during_discover is False
70+
assert source.check_config_against_spec is True
6771

6872

6973
@patch(
@@ -109,7 +113,8 @@ def test_discover_with_dynamic_schema_loader_no_config(mock_streams):
109113

110114
source = ManifestDeclarativeSource(source_config=source_config)
111115

112-
assert source.check_config_against_spec is False
116+
assert source.check_config_during_discover is True
117+
assert source.check_config_against_spec is True
113118

114119
logger = MagicMock()
115120
catalog = source.discover(logger, {})
@@ -152,6 +157,7 @@ def test_discover_without_dynamic_schema_loader_no_config(mock_streams):
152157

153158
source = ManifestDeclarativeSource(source_config=source_config)
154159

160+
assert source.check_config_during_discover is False
155161
assert source.check_config_against_spec is True
156162

157163
logger = MagicMock()
@@ -161,4 +167,5 @@ def test_discover_without_dynamic_schema_loader_no_config(mock_streams):
161167
assert len(catalog.streams) == 1
162168
assert catalog.streams[0].name == "test_static_stream"
163169

170+
assert source.check_config_during_discover is False
164171
assert source.check_config_against_spec is True

0 commit comments

Comments
 (0)