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

Don't show server response in truss push errors #721

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion truss/remote/baseten/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _post_graphql_query(self, query_string: str) -> dict:
resp_dict = resp.json()
errors = resp_dict.get("errors")
if errors:
raise ApiError(errors[0]["message"], resp)
raise ApiError(errors[0]["message"])
return resp_dict

def model_s3_upload_credentials(self):
Expand Down
19 changes: 1 addition & 18 deletions truss/remote/baseten/error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import json


class Error(Exception):
"""Base Baseten Error"""

Expand All @@ -12,21 +9,7 @@ def __init__(self, message):
class ApiError(Error):
"""Errors in calling the Baseten API."""

def __init__(self, message, response=None):
super().__init__(message)
self.response = response

def __str__(self):
error_str = self.message
if (
self.response is not None
): # non-200 Response objects are falsy, hence the not None.
error_message = json.loads(self.response.content)
error_message = (
error_message["error"] if "error" in error_message else error_message
)
error_str = f"{error_str}\n<Server response: {error_message}>"
return error_str
pass


class AuthorizationError(Error):
Expand Down
Loading