Skip to content

Commit d023230

Browse files
fix: preserve backward compatibility for string request_body_json in migration
String-valued request_body_json fields are no longer migrated to RequestBodyPlainText (which now correctly routes to request_body_data). Instead, they are left as request_body_json to preserve their original JSON body semantics via InterpolatedNestedRequestInputProvider. Co-Authored-By: syed.khadeer@airbyte.io <cloud-support@airbyte.io>
1 parent 92cf499 commit d023230

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

airbyte_cdk/manifest_migrations/migrations/http_requester_request_body_json_data_to_request_body.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ class HttpRequesterRequestBodyJsonDataToRequestBody(ManifestMigration):
2626
replacement_key = "request_body"
2727

2828
def should_migrate(self, manifest: ManifestType) -> bool:
29-
return manifest[TYPE_TAG] == self.component_type and any(
30-
key in list(manifest.keys()) for key in self.original_keys
31-
)
29+
if manifest[TYPE_TAG] != self.component_type:
30+
return False
31+
for key in self.original_keys:
32+
if key in manifest:
33+
if key == self.body_json_key and isinstance(manifest[key], str):
34+
continue
35+
return True
36+
return False
3237

3338
def migrate(self, manifest: ManifestType) -> None:
3439
for key in self.original_keys:
@@ -38,9 +43,18 @@ def migrate(self, manifest: ManifestType) -> None:
3843
self._migrate_body_data(manifest, key)
3944

4045
def validate(self, manifest: ManifestType) -> bool:
41-
return self.replacement_key in manifest and all(
42-
key not in manifest for key in self.original_keys
46+
has_replacement = self.replacement_key in manifest
47+
has_unmigrated = any(
48+
key in manifest
49+
for key in self.original_keys
50+
if not (key == self.body_json_key and isinstance(manifest.get(key), str))
51+
)
52+
has_string_json = self.body_json_key in manifest and isinstance(
53+
manifest[self.body_json_key], str
4354
)
55+
if has_string_json:
56+
return not has_unmigrated
57+
return has_replacement and not has_unmigrated
4458

4559
def _migrate_body_json(self, manifest: ManifestType, key: str) -> None:
4660
"""
@@ -52,7 +66,7 @@ def _migrate_body_json(self, manifest: ManifestType, key: str) -> None:
5266
json_object_type = "RequestBodyJsonObject"
5367

5468
if isinstance(manifest[key], str):
55-
self._migrate_value(manifest, key, text_type)
69+
return
5670
elif isinstance(manifest[key], dict):
5771
if isinstance(manifest[key].get(query_key), str):
5872
self._migrate_value(manifest, key, graph_ql_type)

unit_tests/manifest_migrations/conftest.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,7 @@ def expected_manifest_with_migrated_to_request_body() -> Dict[str, Any]:
941941
"type": "HttpRequester",
942942
"http_method": "GET",
943943
"url": "https://example.com/v2/path_to_B",
944-
"request_body": {
945-
"type": "RequestBodyPlainText",
946-
"value": '{"nested": { "key": "{{ config[\'option\'] }}" }}',
947-
},
944+
"request_body_json": '{"nested": { "key": "{{ config[\'option\'] }}" }}',
948945
},
949946
"record_selector": {
950947
"type": "RecordSelector",
@@ -1102,10 +1099,7 @@ def expected_manifest_with_migrated_to_request_body() -> Dict[str, Any]:
11021099
"type": "HttpRequester",
11031100
"http_method": "GET",
11041101
"url": "https://example.com/v2/path_to_B",
1105-
"request_body": {
1106-
"type": "RequestBodyPlainText",
1107-
"value": '{"nested": { "key": "{{ config[\'option\'] }}" }}',
1108-
},
1102+
"request_body_json": '{"nested": { "key": "{{ config[\'option\'] }}" }}',
11091103
},
11101104
"record_selector": {
11111105
"type": "RecordSelector",

0 commit comments

Comments
 (0)