Skip to content

Commit

Permalink
fix passing empty body
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbuniat committed Jan 16, 2022
1 parent 3e26e87 commit 54dfd9c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions hub/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,16 @@ def request(
requests.Response: The response received from the server.
"""
params = params or {}
data = data or {}
files = files or {}
json = json or {}
data = data or None
files = files or None
json = json or None
endpoint = endpoint or self.endpoint()
endpoint = endpoint.strip("/")
relative_url = relative_url.strip("/")
request_url = f"{endpoint}/{relative_url}"
headers = headers or {}
headers["hub-cli-version"] = self.version
headers["Authorization"] = self.auth_header

response = requests.request(
method,
request_url,
Expand All @@ -104,7 +103,7 @@ def request(
)

# clearer error than `ServerUnderMaintenence`
if "password" in json and json["password"] is None:
if json is not None and "password" in json and json["password"] is None:
# do NOT pass in the password here. `None` is explicitly typed.
raise InvalidPasswordException("Password cannot be `None`.")

Expand Down

0 comments on commit 54dfd9c

Please sign in to comment.