From adc16435d04a7fabd4bfd19b396b86c9a962c528 Mon Sep 17 00:00:00 2001 From: Eric Boucher Date: Sat, 2 Jul 2022 11:22:20 +0200 Subject: [PATCH 1/4] Output full path in error messages --- singer_sdk/streams/rest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/singer_sdk/streams/rest.py b/singer_sdk/streams/rest.py index 983abefd6..381c38442 100644 --- a/singer_sdk/streams/rest.py +++ b/singer_sdk/streams/rest.py @@ -16,6 +16,7 @@ TypeVar, Union, ) +from urllib.parse import urlparse import backoff import requests @@ -186,6 +187,7 @@ def response_error_message(self, response: requests.Response) -> str: Returns: str: The error message """ + full_path = urlparse(response.url).path if 400 <= response.status_code < 500: error_type = "Client" else: @@ -193,7 +195,7 @@ def response_error_message(self, response: requests.Response) -> str: return ( f"{response.status_code} {error_type} Error: " - f"{response.reason} for path: {self.path}" + f"{response.reason} for path: {full_path}" ) def request_decorator(self, func: Callable) -> Callable: From c14296bea9995c7ea242d26552a7e30becc6baea Mon Sep 17 00:00:00 2001 From: Eric Boucher Date: Sat, 2 Jul 2022 11:45:14 +0200 Subject: [PATCH 2/4] Update rest.py --- singer_sdk/streams/rest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singer_sdk/streams/rest.py b/singer_sdk/streams/rest.py index 381c38442..f7e50568e 100644 --- a/singer_sdk/streams/rest.py +++ b/singer_sdk/streams/rest.py @@ -187,7 +187,7 @@ def response_error_message(self, response: requests.Response) -> str: Returns: str: The error message """ - full_path = urlparse(response.url).path + full_path = urlparse(response.url).path or self.path if 400 <= response.status_code < 500: error_type = "Client" else: From 737ba7f4f68eb1d0b319c30c3b7e49b4180a3aef Mon Sep 17 00:00:00 2001 From: Eric Boucher Date: Mon, 11 Jul 2022 14:15:34 +0200 Subject: [PATCH 3/4] Add warning in method --- singer_sdk/streams/rest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/singer_sdk/streams/rest.py b/singer_sdk/streams/rest.py index f7e50568e..d78be1d4c 100644 --- a/singer_sdk/streams/rest.py +++ b/singer_sdk/streams/rest.py @@ -180,6 +180,7 @@ def validate_response(self, response: requests.Response) -> None: def response_error_message(self, response: requests.Response) -> str: """Build error message for invalid http statuses. + WARNING - Override this method when the URL path may contain secrets or PII Args: response: A `requests.Response`_ object. From 24e0e94770482f2bd47eebc1cdea23c8be889c24 Mon Sep 17 00:00:00 2001 From: Eric Boucher Date: Mon, 11 Jul 2022 14:33:16 +0200 Subject: [PATCH 4/4] Update rest.py --- singer_sdk/streams/rest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/singer_sdk/streams/rest.py b/singer_sdk/streams/rest.py index d78be1d4c..934cc23e6 100644 --- a/singer_sdk/streams/rest.py +++ b/singer_sdk/streams/rest.py @@ -180,6 +180,7 @@ def validate_response(self, response: requests.Response) -> None: def response_error_message(self, response: requests.Response) -> str: """Build error message for invalid http statuses. + WARNING - Override this method when the URL path may contain secrets or PII Args: