Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connector-builder: return full url-encoded URL instead of separating parameters #36680

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,12 @@ def _parse_json(log_message: AirbyteLogMessage) -> JsonType:

@staticmethod
def _create_request_from_log_message(json_http_message: Dict[str, Any]) -> HttpRequest:
url = urlparse(json_http_message.get("url", {}).get("full", ""))
full_path = f"{url.scheme}://{url.hostname}{url.path}" if url else ""
url = json_http_message.get("url", {}).get("full", "")
request = json_http_message.get("http", {}).get("request", {})
parameters = parse_qs(url.query) or None
return HttpRequest(
url=full_path,
url=url,
http_method=request.get("method", ""),
headers=request.get("headers"),
parameters=parameters,
body=request.get("body", {}).get("content", ""),
)

Expand Down
1 change: 0 additions & 1 deletion airbyte-cdk/python/airbyte_cdk/connector_builder/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class HttpResponse:
@dataclass
class HttpRequest:
url: str
parameters: Optional[Dict[str, Any]]
headers: Optional[Dict[str, Any]]
http_method: str
body: Optional[str] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def test_get_grouped_messages(mock_entrypoint_read: Mock) -> None:
expected_pages = [
StreamReadPages(
request=HttpRequest(
url="https://demonslayers.com/api/v1/hashiras",
parameters={"era": ["taisho"]},
url="https://demonslayers.com/api/v1/hashiras?era=taisho",
headers={"Content-Type": "application/json"},
body='{"custom": "field"}',
http_method="GET",
Expand All @@ -117,8 +116,7 @@ def test_get_grouped_messages(mock_entrypoint_read: Mock) -> None:
),
StreamReadPages(
request=HttpRequest(
url="https://demonslayers.com/api/v1/hashiras",
parameters={"era": ["taisho"]},
url="https://demonslayers.com/api/v1/hashiras?era=taisho",
headers={"Content-Type": "application/json"},
body='{"custom": "field"}',
http_method="GET",
Expand Down Expand Up @@ -166,8 +164,7 @@ def test_get_grouped_messages_with_logs(mock_entrypoint_read: Mock) -> None:
expected_pages = [
StreamReadPages(
request=HttpRequest(
url="https://demonslayers.com/api/v1/hashiras",
parameters={"era": ["taisho"]},
url="https://demonslayers.com/api/v1/hashiras?era=taisho",
headers={"Content-Type": "application/json"},
body='{"custom": "field"}',
http_method="GET",
Expand All @@ -177,8 +174,7 @@ def test_get_grouped_messages_with_logs(mock_entrypoint_read: Mock) -> None:
),
StreamReadPages(
request=HttpRequest(
url="https://demonslayers.com/api/v1/hashiras",
parameters={"era": ["taisho"]},
url="https://demonslayers.com/api/v1/hashiras?era=taisho",
headers={"Content-Type": "application/json"},
body='{"custom": "field"}',
http_method="GET",
Expand Down Expand Up @@ -351,8 +347,7 @@ def test_get_grouped_messages_no_records(mock_entrypoint_read: Mock) -> None:
expected_pages = [
StreamReadPages(
request=HttpRequest(
url="https://demonslayers.com/api/v1/hashiras",
parameters={"era": ["taisho"]},
url="https://demonslayers.com/api/v1/hashiras?era=taisho",
headers={"Content-Type": "application/json"},
body='{"custom": "field"}',
http_method="GET",
Expand All @@ -362,8 +357,7 @@ def test_get_grouped_messages_no_records(mock_entrypoint_read: Mock) -> None:
),
StreamReadPages(
request=HttpRequest(
url="https://demonslayers.com/api/v1/hashiras",
parameters={"era": ["taisho"]},
url="https://demonslayers.com/api/v1/hashiras?era=taisho",
headers={"Content-Type": "application/json"},
body='{"custom": "field"}',
http_method="GET",
Expand Down
Loading