Skip to content

Commit 426ab5b

Browse files
authored
fix(low-code): add wrong dynamic stream name type validation (#305)
1 parent e57d38a commit 426ab5b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ def _dynamic_stream_configs(
365365
# Ensure that each stream is created with a unique name
366366
name = dynamic_stream.get("name")
367367

368+
if not isinstance(name, str):
369+
raise ValueError(
370+
f"Expected stream name {name} to be a string, got {type(name)}."
371+
)
372+
368373
if name in seen_dynamic_streams:
369374
error_message = f"Dynamic streams list contains a duplicate name: {name}. Please contact Airbyte Support."
370375
failure_type = FailureType.system_error

unit_tests/sources/declarative/resolvers/test_http_components_resolver.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
import json
6+
from copy import deepcopy
67
from unittest.mock import MagicMock
78

89
import pytest
@@ -362,6 +363,34 @@ def test_http_components_resolver(
362363
assert result == expected_result
363364

364365

366+
def test_wrong_stream_name_type():
367+
with HttpMocker() as http_mocker:
368+
http_mocker.get(
369+
HttpRequest(url="https://api.test.com/int_items"),
370+
HttpResponse(
371+
body=json.dumps(
372+
[
373+
{"id": 1, "name": 1},
374+
{"id": 2, "name": 2},
375+
]
376+
)
377+
),
378+
)
379+
380+
manifest = deepcopy(_MANIFEST)
381+
manifest["dynamic_streams"][0]["components_resolver"]["retriever"]["requester"]["path"] = (
382+
"int_items"
383+
)
384+
385+
source = ConcurrentDeclarativeSource(
386+
source_config=manifest, config=_CONFIG, catalog=None, state=None
387+
)
388+
with pytest.raises(ValueError) as exc_info:
389+
source.discover(logger=source.logger, config=_CONFIG)
390+
391+
assert str(exc_info.value) == "Expected stream name 1 to be a string, got <class 'int'>."
392+
393+
365394
@pytest.mark.parametrize(
366395
"components_mapping, retriever_data, stream_template_config, expected_result",
367396
[

0 commit comments

Comments
 (0)