Skip to content

Commit

Permalink
CDK: don't filter failed interpolated vars for `request_options_provi…
Browse files Browse the repository at this point in the history
…der.request_body_json` (#19297)

Signed-off-by: Sergey Chvalyuk <[email protected]>
  • Loading branch information
grubberr authored Nov 11, 2022
1 parent 8a0d12f commit 5cd88e7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions airbyte-cdk/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.9.1
Low-code: Fix filtering vars in `InterpolatedRequestInputProvider.eval_request_inputs`

## 0.9.0
Low-code: Allow `grant_type` to be specified for OAuthAuthenticator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_access_token_name(self) -> InterpolatedString:

def get_expires_in_name(self) -> InterpolatedString:
return self.expires_in_name.eval(self.config)

def get_grant_type(self) -> InterpolatedString:
return self.grant_type.eval(self.config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def eval_request_inputs(
interpolated_value = self._interpolator.eval(self.config, **kwargs)

if isinstance(interpolated_value, dict):
non_null_tokens = {k: v for k, v in interpolated_value.items() if v}
non_null_tokens = {k: v for k, v in interpolated_value.items() if v is not None}
return non_null_tokens
return interpolated_value
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_expires_in_name(self) -> str:
@abstractmethod
def get_refresh_request_body(self) -> Mapping[str, Any]:
"""Returns the request body to set on the refresh request"""

@abstractmethod
def get_grant_type(self) -> str:
"""Returns grant_type specified for requesting access_token"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_expires_in_name(self) -> str:

def get_refresh_request_body(self) -> Mapping[str, Any]:
return self._refresh_request_body

def get_grant_type(self) -> str:
return self._grant_type

Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name="airbyte-cdk",
version="0.8.1",
version="0.9.1",
description="A framework for writing Airbyte Connectors.",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@
("test_value_depends_on_stream_slice", {"read_from_slice": "{{ stream_slice['start_date'] }}"}, {"read_from_slice": "2020-01-01"}),
("test_value_depends_on_next_page_token", {"read_from_token": "{{ next_page_token['offset'] }}"}, {"read_from_token": 12345}),
("test_value_depends_on_config", {"read_from_config": "{{ config['option'] }}"}, {"read_from_config": "OPTION"}),
("test_none_value", {"missing_param": "{{ fake_path['date'] }}"}, {}),
("test_missing_value", {"missing_param": "{{ fake_path['date'] }}"}, {}),
(
"test_parameter_is_interpolated",
{"{{ stream_state['date'] }} - {{stream_slice['start_date']}} - {{next_page_token['offset']}} - {{config['option']}}": "ABC"},
{"2021-01-01 - 2020-01-01 - 12345 - OPTION": "ABC"},
),
("test_boolean_false_value", {"boolean_false": "{{ False }}"}, {"boolean_false": False}),
("test_integer_falsy_value", {"integer_falsy": "{{ 0 }}"}, {"integer_falsy": 0}),
("test_number_falsy_value", {"number_falsy": "{{ 0.0 }}"}, {"number_falsy": 0.0}),
("test_string_falsy_value", {"string_falsy": "{{ '' }}"}, {}),
("test_none_value", {"none_value": "{{ None }}"}, {}),
],
)
def test_interpolated_request_params(test_name, input_request_params, expected_request_params):
Expand All @@ -45,12 +50,17 @@ def test_interpolated_request_params(test_name, input_request_params, expected_r
("test_value_depends_on_stream_slice", {"read_from_slice": "{{ stream_slice['start_date'] }}"}, {"read_from_slice": "2020-01-01"}),
("test_value_depends_on_next_page_token", {"read_from_token": "{{ next_page_token['offset'] }}"}, {"read_from_token": 12345}),
("test_value_depends_on_config", {"read_from_config": "{{ config['option'] }}"}, {"read_from_config": "OPTION"}),
("test_none_value", {"missing_json": "{{ fake_path['date'] }}"}, {}),
("test_missing_value", {"missing_json": "{{ fake_path['date'] }}"}, {}),
(
"test_interpolated_keys",
{"{{ stream_state['date'] }}": 123, "{{ config['option'] }}": "ABC"},
{"2021-01-01": 123, "OPTION": "ABC"},
),
("test_boolean_false_value", {"boolean_false": "{{ False }}"}, {"boolean_false": False}),
("test_integer_falsy_value", {"integer_falsy": "{{ 0 }}"}, {"integer_falsy": 0}),
("test_number_falsy_value", {"number_falsy": "{{ 0.0 }}"}, {"number_falsy": 0.0}),
("test_string_falsy_value", {"string_falsy": "{{ '' }}"}, {}),
("test_none_value", {"none_value": "{{ None }}"}, {}),
],
)
def test_interpolated_request_json(test_name, input_request_json, expected_request_json):
Expand Down

0 comments on commit 5cd88e7

Please sign in to comment.