Skip to content

Commit 2a50950

Browse files
author
maxime.c
committed
fixes while testing
1 parent 37698f5 commit 2a50950

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,9 @@ def interpret_response(
6666
if not isinstance(matched_error_resolution, ErrorResolution):
6767
continue
6868

69-
if matched_error_resolution.response_action == ResponseAction.SUCCESS:
69+
if matched_error_resolution.response_action in [ResponseAction.SUCCESS, ResponseAction.RETRY, ResponseAction.IGNORE, ResponseAction.RESET_PAGINATION]:
7070
return matched_error_resolution
7171

72-
if (
73-
matched_error_resolution.response_action == ResponseAction.RETRY
74-
or matched_error_resolution.response_action == ResponseAction.IGNORE
75-
):
76-
return matched_error_resolution
7772
if matched_error_resolution:
7873
return matched_error_resolution
7974

airbyte_cdk/test/mock_http/response_builder.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ def __str__(self) -> str:
7575
return f"NestedPath(path={self._path})"
7676

7777

78+
class RootPath(Path):
79+
"""
80+
Path to use when the root of the response is an array.
81+
"""
82+
83+
def write(self, template: List[Dict[str, Any]], value: List[Dict[str, Any]]) -> None:
84+
template.extend(value)
85+
86+
def update(self, template: List[Dict[str, Any]], value: List[Any]) -> None:
87+
template.clear()
88+
template.extend(value)
89+
90+
def extract(self, template: List[Dict[str, Any]]) -> Any:
91+
return template
92+
93+
def __str__(self) -> str:
94+
return f"RootPath"
95+
96+
7897
class PaginationStrategy(ABC):
7998
@abstractmethod
8099
def update(self, response: Dict[str, Any]) -> None:
@@ -95,7 +114,7 @@ def __init__(
95114
self,
96115
template: Dict[str, Any],
97116
id_path: Optional[Path],
98-
cursor_path: Optional[Union[FieldPath, NestedPath]],
117+
cursor_path: Optional[Union[FieldPath, NestedPath, RootPath]],
99118
):
100119
self._record = template
101120
self._id_path = id_path
@@ -150,7 +169,7 @@ class HttpResponseBuilder:
150169
def __init__(
151170
self,
152171
template: Dict[str, Any],
153-
records_path: Union[FieldPath, NestedPath],
172+
records_path: Union[FieldPath, NestedPath, RootPath],
154173
pagination_strategy: Optional[PaginationStrategy],
155174
):
156175
self._response = template
@@ -208,9 +227,9 @@ def find_binary_response(resource: str, execution_folder: str) -> bytes:
208227

209228
def create_record_builder(
210229
response_template: Dict[str, Any],
211-
records_path: Union[FieldPath, NestedPath],
230+
records_path: Union[FieldPath, NestedPath, RootPath],
212231
record_id_path: Optional[Path] = None,
213-
record_cursor_path: Optional[Union[FieldPath, NestedPath]] = None,
232+
record_cursor_path: Optional[Union[FieldPath, NestedPath, RootPath]] = None,
214233
) -> RecordBuilder:
215234
"""
216235
This will use the first record define at `records_path` as a template for the records. If more records are defined, they will be ignored
@@ -231,7 +250,7 @@ def create_record_builder(
231250

232251
def create_response_builder(
233252
response_template: Dict[str, Any],
234-
records_path: Union[FieldPath, NestedPath],
253+
records_path: Union[FieldPath, NestedPath, RootPath],
235254
pagination_strategy: Optional[PaginationStrategy] = None,
236255
) -> HttpResponseBuilder:
237256
return HttpResponseBuilder(response_template, records_path, pagination_strategy)

0 commit comments

Comments
 (0)