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

feat: Output full URL path in error messages #785

Merged
merged 5 commits into from
Jul 11, 2022
Merged
Changes from all commits
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
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