Skip to content

Commit 7e52e79

Browse files
fix(check-stream): fall back on empty stream override
1 parent 6ec97a4 commit 7e52e79

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

airbyte_cdk/sources/declarative/checks/check_stream.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,16 @@ def check_connection(
105105
return True, None
106106

107107
def _get_stream_names(self, config: Mapping[str, Any]) -> List[str]:
108-
if CHECK_STREAM_NAMES_CONFIG_KEY not in config:
108+
if (
109+
CHECK_STREAM_NAMES_CONFIG_KEY not in config
110+
or config[CHECK_STREAM_NAMES_CONFIG_KEY] == []
111+
):
109112
return self.stream_names
110113
configured_stream_names = config[CHECK_STREAM_NAMES_CONFIG_KEY]
111114
if not isinstance(configured_stream_names, list) or not all(
112115
isinstance(stream_name, str) for stream_name in configured_stream_names
113116
):
114117
raise ValueError(f"{CHECK_STREAM_NAMES_CONFIG_KEY} must be a list of strings.")
115-
# An empty override intentionally skips static stream checks; dynamic stream checks still run when configured.
116118
return configured_stream_names
117119

118120
def _check_stream_availability(

unit_tests/sources/declarative/checks/test_check_stream.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ def test_check_stream_names_can_be_overridden_from_config():
9898
static_stream.stream_slices.assert_not_called()
9999

100100

101-
def test_check_stream_names_override_accepts_empty_list():
101+
def test_check_stream_names_override_empty_list_falls_back_to_manifest_streams():
102102
stream = MagicMock(spec=Stream)
103103
stream.name = "static_stream"
104104
stream.availability_strategy = None
105+
stream.read_records.return_value = iter([record])
106+
stream.stream_slices.return_value = iter([{}])
105107
source = MagicMock()
106108
source.streams.return_value = [stream]
107109

@@ -111,7 +113,7 @@ def test_check_stream_names_override_accepts_empty_list():
111113
True,
112114
None,
113115
)
114-
stream.stream_slices.assert_not_called()
116+
stream.stream_slices.assert_called_once()
115117

116118

117119
@pytest.mark.parametrize("override", ["selected_stream", [1], ["selected_stream", 1], None])
@@ -794,7 +796,7 @@ def test_check_stream1(
794796
assert connection_status.status == expected_result
795797

796798

797-
def test_check_empty_static_stream_override_still_checks_dynamic_streams():
799+
def test_check_empty_static_stream_override_falls_back_to_manifest_streams_and_checks_dynamic_streams():
798800
manifest = {
799801
**deepcopy(_MANIFEST_WITHOUT_CHECK_COMPONENT),
800802
**{
@@ -840,9 +842,9 @@ def test_check_empty_static_stream_override_still_checks_dynamic_streams():
840842

841843
connection_status = source.check(logger, check_config)
842844

843-
http_mocker.assert_number_of_calls(static_stream_request, 0)
844-
http_mocker.assert_number_of_calls(item_request_2, 1)
845-
assert connection_status.status == Status.SUCCEEDED
845+
http_mocker.assert_number_of_calls(static_stream_request, 6)
846+
http_mocker.assert_number_of_calls(item_request_2, 0)
847+
assert connection_status.status == Status.FAILED
846848

847849

848850
def test_check_stream_missing_fields():

0 commit comments

Comments
 (0)