Skip to content

Commit 4a08016

Browse files
Require stream_count >= 1; drop zero-means-skip behavior
Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
1 parent 932539d commit 4a08016

4 files changed

Lines changed: 13 additions & 49 deletions

File tree

airbyte_cdk/sources/declarative/checks/check_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def _check_generated_streams_availability(
166166
) -> Tuple[bool, Any]:
167167
"""Checks availability of generated dynamic streams.
168168
169-
If `max_count` is `None`, all generated streams are checked. If `max_count` is 0,
170-
no streams are checked. Otherwise, the first `max_count` streams are checked.
169+
If `max_count` is `None`, all generated streams are checked. Otherwise, the
170+
first `max_count` streams are checked (capped at the number of available streams).
171171
"""
172172
streams_to_check = (
173173
generated_streams if max_count is None else generated_streams[:max_count]

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ definitions:
358358
type: string
359359
stream_count:
360360
title: Stream Count
361-
description: The number of streams to attempt reading from during a check operation. If unset, all generated streams are checked. If set to 0, no streams are checked. If set to a positive value greater than the total number of available streams, all streams are checked.
361+
description: The number of streams to attempt reading from during a check operation. If unset, all generated streams are checked. Must be a positive integer; if it exceeds the total number of available streams, all streams are checked.
362362
type: integer
363-
minimum: 0
363+
minimum: 1
364364
CheckDynamicStream:
365365
title: Dynamic Streams to Check
366366
description: (This component is experimental. Use at your own risk.) Defines the dynamic streams to try reading when running a check operation.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class DynamicStreamCheckConfig(BaseModel):
5959
)
6060
stream_count: Optional[int] = Field(
6161
None,
62-
description="The number of streams to attempt reading from during a check operation. If unset, all generated streams are checked. If set to 0, no streams are checked. If set to a positive value greater than the total number of available streams, all streams are checked.",
63-
ge=0,
62+
description="The number of streams to attempt reading from during a check operation. If unset, all generated streams are checked. Must be a positive integer; if it exceeds the total number of available streams, all streams are checked.",
63+
ge=1,
6464
title="Stream Count",
6565
)
6666

unit_tests/sources/declarative/checks/test_check_stream.py

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -487,46 +487,6 @@ 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-
0,
508-
id="test_stream_count_zero_checks_no_streams",
509-
),
510-
pytest.param(
511-
{
512-
"check": {
513-
"type": "CheckStream",
514-
"dynamic_streams_check_configs": [
515-
{
516-
"type": "DynamicStreamCheckConfig",
517-
"dynamic_stream_name": "http_dynamic_stream",
518-
"stream_count": 0,
519-
},
520-
],
521-
}
522-
},
523-
Status.SUCCEEDED,
524-
False,
525-
404,
526-
["Not found. The requested resource was not found on the server."],
527-
0,
528-
id="test_stream_count_zero_skips_failing_streams",
529-
),
530490
pytest.param(
531491
{
532492
"check": {
@@ -760,8 +720,12 @@ def test_check_stream_missing_fields():
760720
)
761721

762722

763-
def test_check_stream_negative_stream_count():
764-
"""Test that a ValidationError is raised when stream_count is negative."""
723+
@pytest.mark.parametrize(
724+
"stream_count",
725+
[pytest.param(0, id="zero"), pytest.param(-1, id="negative")],
726+
)
727+
def test_check_stream_non_positive_stream_count(stream_count: int) -> None:
728+
"""A ValidationError is raised when stream_count is less than 1."""
765729
manifest = {
766730
**deepcopy(_MANIFEST_WITHOUT_CHECK_COMPONENT),
767731
**{
@@ -771,7 +735,7 @@ def test_check_stream_negative_stream_count():
771735
{
772736
"type": "DynamicStreamCheckConfig",
773737
"dynamic_stream_name": "http_dynamic_stream",
774-
"stream_count": -1,
738+
"stream_count": stream_count,
775739
}
776740
],
777741
}

0 commit comments

Comments
 (0)