Skip to content

Commit 4a6d25a

Browse files
authored
Improving OAuth error messages (#453)
1 parent 0f57371 commit 4a6d25a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

databricks_cli/oauth/oauth.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,21 @@ def fetch_well_known_config(idp_url):
9191
try:
9292
response = requests.request(method="GET", url=known_config_url)
9393
except RequestException:
94-
error_and_quit("Unable to fetch OAuth configuration from {idp_url}."
95-
"Verify that OAuth is enabled on this account.".format(idp_url=idp_url))
94+
error_and_quit("Unable to fetch OAuth configuration from {idp_url}.\n"
95+
"Verify it is a valid workspace URL and that OAuth is "
96+
"enabled on this account.".format(idp_url=idp_url))
9697

9798
if response.status_code != 200:
98-
error_and_quit("Unable to fetch OAuth configuration from {idp_url}. "
99-
"Verify that OAuth is enabled on this account.".format(idp_url=idp_url))
100-
return json.loads(response.text)
99+
error_and_quit("Received status {status} OAuth configuration from "
100+
"{idp_url}.\n Verify it is a valid workspace URL and "
101+
"that OAuth is enabled on this account."
102+
.format(status=response.status_code, idp_url=idp_url))
103+
try:
104+
return json.loads(response.text)
105+
except json.decoder.JSONDecodeError:
106+
error_and_quit("Unable to decode OAuth configuration from {idp_url}.\n"
107+
"Verify it is a valid workspace URL and that OAuth is "
108+
"enabled on this account.".format(idp_url=idp_url))
101109

102110

103111
def get_idp_url(host):

0 commit comments

Comments
 (0)