From 18da341b916f58cc4f8fac491df9e36c07ed8cc2 Mon Sep 17 00:00:00 2001 From: Alexandre Girard Date: Thu, 6 Oct 2022 18:43:01 -0700 Subject: [PATCH] Revert: #17047 Airbyte CDK: Improve error for returning non-iterable from connectors parse_response (#17707) * Bump cdk version * Revert "#17047 Airbyte CDK: Improve error for returning non-iterable from connectors parse_response (#17626)" This reverts commit d9ad2725b1d361dfabb1d2df7a77080e478e80ad. * Bump --- airbyte-cdk/python/CHANGELOG.md | 8 ++++++++ .../python/airbyte_cdk/models/airbyte_protocol.py | 12 +----------- airbyte-cdk/python/setup.py | 2 +- .../unit_tests/sources/test_abstract_source.py | 12 ------------ 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/airbyte-cdk/python/CHANGELOG.md b/airbyte-cdk/python/CHANGELOG.md index 795243c6da1e4..42336f27519c1 100644 --- a/airbyte-cdk/python/CHANGELOG.md +++ b/airbyte-cdk/python/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.97 + +- Revert 0.1.96 + +## 0.1.96 + +- Improve error for returning non-iterable from connectors parse_response + ## 0.1.95 - Low-code: Expose PageIncrement strategy as component type diff --git a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py index 9a1c86ef317f6..8ccf522e6cdda 100644 --- a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py +++ b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py @@ -10,7 +10,7 @@ from enum import Enum from typing import Any, Dict, List, Optional, Union -from pydantic import AnyUrl, BaseModel, Extra, Field, validator +from pydantic import AnyUrl, BaseModel, Extra, Field class Type(Enum): @@ -35,16 +35,6 @@ class Config: description="when the data was emitted from the source. epoch in millisecond.", ) - @validator("data", pre=True) - def data_is_dict(cls: AirbyteRecordMessage, value: Dict[str, Any]): - if isinstance(value, dict): - return value - raise ValueError("Data object is not a dictionary. " - "This can happen when the parse_response method directly returns the response.json, " - "instead of yielding a it/elements of it." - f"Object instead is {type(value)} with value: {value}" - ) - class AirbyteStateType(Enum): GLOBAL = "GLOBAL" diff --git a/airbyte-cdk/python/setup.py b/airbyte-cdk/python/setup.py index 6fd70b8f799ff..91fc927ab34db 100644 --- a/airbyte-cdk/python/setup.py +++ b/airbyte-cdk/python/setup.py @@ -15,7 +15,7 @@ setup( name="airbyte-cdk", - version="0.1.95", + version="0.1.97", description="A framework for writing Airbyte Connectors.", long_description=README, long_description_content_type="text/markdown", diff --git a/airbyte-cdk/python/unit_tests/sources/test_abstract_source.py b/airbyte-cdk/python/unit_tests/sources/test_abstract_source.py index f73afd76ce049..7696a058383fe 100644 --- a/airbyte-cdk/python/unit_tests/sources/test_abstract_source.py +++ b/airbyte-cdk/python/unit_tests/sources/test_abstract_source.py @@ -800,15 +800,3 @@ def test_checkpoint_state_from_stream_instance(): assert actual_message == _as_state( {"teams": {"updated_at": "2022-09-11"}, "managers": {"updated": "expected_here"}}, "managers", {"updated": "expected_here"} ) - - -def test_airbyte_record_message_custom_data_validation_error(): - invalid_data = "Not a dict" - with pytest.raises(ValueError): - AirbyteRecordMessage(stream="stream", data=invalid_data, emitted_at=GLOBAL_EMITTED_AT) - - -def test_airbyte_record_message_valid_data(): - valid_data = {"foo": "bar"} - AirbyteRecordMessage(stream="stream", data=valid_data, emitted_at=GLOBAL_EMITTED_AT) -