Skip to content

Commit 7b95a10

Browse files
devin-ai-integration[bot]bot_apk
andcommitted
fix: treat stream_count=0 as 'check all streams' in DynamicStreamCheckConfig
Previously, DynamicStreamCheckConfig.stream_count defaulted to 0, which caused _check_generated_streams_availability to slice generated_streams[:0], resulting in zero streams being checked. This meant connectors using DynamicStreamCheckConfig without explicitly setting stream_count would silently skip all dynamic stream availability checks. Now, stream_count <= 0 means 'check all generated streams', which is the expected behavior when no limit is specified. Co-Authored-By: bot_apk <apk@cognition.ai>
1 parent 1256a1f commit 7b95a10

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

airbyte_cdk/sources/declarative/checks/check_stream.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ def _check_generated_streams_availability(
164164
logger: logging.Logger,
165165
max_count: int,
166166
) -> Tuple[bool, Any]:
167-
"""Checks availability of generated dynamic streams."""
168-
for declarative_stream in generated_streams[: min(max_count, len(generated_streams))]:
167+
"""Checks availability of generated dynamic streams.
168+
169+
If max_count is 0 or negative, all generated streams are checked.
170+
"""
171+
streams_to_check = generated_streams if max_count <= 0 else generated_streams[:max_count]
172+
for declarative_stream in streams_to_check:
169173
stream = stream_name_to_stream[declarative_stream["name"]]
170174
try:
171175
stream_is_available, reason = evaluate_availability(stream, logger)

unit_tests/sources/declarative/checks/test_check_stream.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
439439
False,
440440
200,
441441
[],
442-
0,
442+
1,
443443
id="test_check_http_dynamic_stream_and_config_dynamic_stream",
444444
),
445445
pytest.param(
@@ -464,7 +464,7 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
464464
False,
465465
200,
466466
[],
467-
0,
467+
1,
468468
id="test_check_static_streams_and_http_dynamic_stream_and_config_dynamic_stream",
469469
),
470470
pytest.param(
@@ -487,6 +487,26 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
487487
1,
488488
id="test_stream_count_gt_generated_streams",
489489
),
490+
pytest.param(
491+
{
492+
"check": {
493+
"type": "CheckStream",
494+
"dynamic_streams_check_configs": [
495+
{
496+
"type": "DynamicStreamCheckConfig",
497+
"dynamic_stream_name": "http_dynamic_stream",
498+
"stream_count": 0,
499+
},
500+
],
501+
}
502+
},
503+
Status.SUCCEEDED,
504+
False,
505+
200,
506+
[],
507+
1,
508+
id="test_stream_count_zero_checks_all_streams",
509+
),
490510
pytest.param(
491511
{"check": {"type": "CheckStream", "stream_names": ["non_existent_stream"]}},
492512
Status.FAILED,

0 commit comments

Comments
 (0)