Skip to content

Commit 0bec3f7

Browse files
committed
Merge branch 'christo/manifest-server-errors' of https://github.com/airbytehq/airbyte-python-cdk into christo/manifest-server-errors
2 parents b7bf3c8 + 4f7ac0f commit 0bec3f7

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

airbyte_cdk/manifest_server/routers/manifest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
from fastapi.responses import JSONResponse
99

1010
from airbyte_cdk.models import AirbyteStateMessageSerializer
11-
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
1211
from airbyte_cdk.sources.declarative.concurrent_declarative_source import (
1312
ConcurrentDeclarativeSource,
1413
)
1514
from airbyte_cdk.sources.declarative.parsers.custom_code_compiler import (
1615
INJECTED_COMPONENTS_PY,
1716
INJECTED_COMPONENTS_PY_CHECKSUMS,
1817
)
18+
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
1919

2020
from ..api_models import (
2121
CheckRequest,
@@ -161,7 +161,9 @@ def discover(request: DiscoverRequest) -> DiscoverResponse:
161161
runner = ManifestCommandProcessor(source)
162162
catalog = runner.discover(request.config.model_dump())
163163
if catalog is None:
164-
raise HTTPException(status_code=422, detail="Connector did not return a discovered catalog")
164+
raise HTTPException(
165+
status_code=422, detail="Connector did not return a discovered catalog"
166+
)
165167
return DiscoverResponse(catalog=catalog)
166168
except HTTPException:
167169
# Re-raise HTTPExceptions as-is (like the catalog None check above)

unit_tests/manifest_server/routers/test_manifest.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,16 @@ def test_test_read_cdk_error_handling(
538538
request_data = {
539539
"manifest": sample_manifest,
540540
"config": sample_config,
541-
"stream_name": "products"
541+
"stream_name": "products",
542542
}
543543

544544
mock_build_source.return_value = mock_source
545545

546546
mock_runner = Mock()
547547
# Simulate a CDK error (like datetime parsing error)
548-
mock_runner.test_read.side_effect = ValueError("time data '' does not match format '%Y-%m-%dT%H:%M:%SZ'")
548+
mock_runner.test_read.side_effect = ValueError(
549+
"time data '' does not match format '%Y-%m-%dT%H:%M:%SZ'"
550+
)
549551
mock_runner_class.return_value = mock_runner
550552

551553
response = client.post("/v1/manifest/test_read", json=request_data)
@@ -610,9 +612,7 @@ def test_discover_cdk_error_handling(
610612
assert "Schema validation failed" in data["detail"]
611613

612614
@patch("airbyte_cdk.manifest_server.routers.manifest.build_source")
613-
def test_resolve_cdk_error_handling(
614-
self, mock_build_source, sample_manifest
615-
):
615+
def test_resolve_cdk_error_handling(self, mock_build_source, sample_manifest):
616616
"""Test that CDK errors in resolve are properly caught and converted to HTTP 400."""
617617
request_data = {
618618
"manifest": sample_manifest,
@@ -634,11 +634,7 @@ def test_full_resolve_cdk_error_handling(
634634
self, mock_build_source, sample_manifest, sample_config
635635
):
636636
"""Test that CDK errors in full_resolve are properly caught and converted to HTTP 400."""
637-
request_data = {
638-
"manifest": sample_manifest,
639-
"config": sample_config,
640-
"stream_limit": 10
641-
}
637+
request_data = {"manifest": sample_manifest, "config": sample_config, "stream_limit": 10}
642638

643639
# Simulate a CDK error during source building
644640
mock_build_source.side_effect = KeyError("Missing required field 'streams'")

0 commit comments

Comments
 (0)