Skip to content

Commit

Permalink
feat: Output full URL path in error messages (#785)
Browse files Browse the repository at this point in the history
* Output full path in error messages

* Update rest.py

* Add warning in method

* Update rest.py

Co-authored-by: Edgar R. M <[email protected]>
  • Loading branch information
ericboucher and edgarrmondragon authored Jul 11, 2022
1 parent 6fc504b commit 6a3a72b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
TypeVar,
Union,
)
from urllib.parse import urlparse

import backoff
import requests
Expand Down Expand Up @@ -180,20 +181,23 @@ 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.
Returns:
str: The error message
"""
full_path = urlparse(response.url).path or self.path
if 400 <= response.status_code < 500:
error_type = "Client"
else:
error_type = "Server"

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:
Expand Down

0 comments on commit 6a3a72b

Please sign in to comment.