Skip to content

Commit e4098e1

Browse files
committed
minor fix in error message
1 parent d3b85cb commit e4098e1

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

databricks/sdk/errors/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def _unknown_error(response: requests.Response) -> str:
3838
return (
3939
'This is likely a bug in the Databricks SDK for Python or the underlying '
4040
'API. Please report this issue with the following debugging information to the SDK issue tracker at '
41-
f'https://github.com/databricks/databricks-sdk-go/issues. Request log:```{request_log}```')
41+
f'https://github.com/databricks/databricks-sdk-py/issues. Request log:```{request_log}```'
42+
f' Config: host={response.request.url}, status_code={response.status_code}'
43+
)
4244

4345

4446
class _Parser:

tests/test_errors.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def make_private_link_response() -> requests.Response:
8282
subclass_test_cases = [(fake_valid_response('GET', x[0], x[1], 'nope'), x[2], 'nope')
8383
for x in base_subclass_test_cases]
8484

85+
UNABLE_TO_PARSE_RESPONSE_ERROR = (
86+
'unable to parse response. This is likely a bug in the Databricks SDK for Python or the underlying API. '
87+
'Please report this issue with the following debugging information to the SDK issue tracker at '
88+
'https://github.com/databricks/databricks-sdk-py/issues. Request log:```GET /api/2.0/service\n'
89+
'< {status_code} {reason}\n< {response_body}```'
90+
)
8591

8692
@pytest.mark.parametrize(
8793
'response, expected_error, expected_message', subclass_test_cases +
@@ -112,11 +118,8 @@ def make_private_link_response() -> requests.Response:
112118
(fake_response('GET', 400, '<pre>Worker environment not ready</pre>'), errors.BadRequest,
113119
'Worker environment not ready'),
114120
(fake_response('GET', 400, 'this is not a real response'), errors.BadRequest,
115-
('unable to parse response. This is likely a bug in the Databricks SDK for Python or the underlying API. '
116-
'Please report this issue with the following debugging information to the SDK issue tracker at '
117-
'https://github.com/databricks/databricks-sdk-go/issues. Request log:```GET /api/2.0/service\n'
118-
'< 400 Bad Request\n'
119-
'< this is not a real response```')),
121+
UNABLE_TO_PARSE_RESPONSE_ERROR.format(status_code=400, reason='Bad Request', response_body='this is not a real response')
122+
),
120123
(fake_response(
121124
'GET', 404,
122125
json.dumps({
@@ -125,14 +128,17 @@ def make_private_link_response() -> requests.Response:
125128
'schemas': ['urn:ietf:params:scim:api:messages:2.0:Error']
126129
})), errors.NotFound, 'None Group with id 1234 is not found'),
127130
(fake_response('GET', 404, json.dumps("This is JSON but not a dictionary")), errors.NotFound,
128-
'unable to parse response. This is likely a bug in the Databricks SDK for Python or the underlying API. Please report this issue with the following debugging information to the SDK issue tracker at https://github.com/databricks/databricks-sdk-go/issues. Request log:```GET /api/2.0/service\n< 404 Not Found\n< "This is JSON but not a dictionary"```'
131+
UNABLE_TO_PARSE_RESPONSE_ERROR.format(status_code=404, reason='Not Found', response_body='"This is JSON but not a dictionary"')
129132
),
130133
(fake_raw_response('GET', 404, b'\x80'), errors.NotFound,
131-
'unable to parse response. This is likely a bug in the Databricks SDK for Python or the underlying API. Please report this issue with the following debugging information to the SDK issue tracker at https://github.com/databricks/databricks-sdk-go/issues. Request log:```GET /api/2.0/service\n< 404 Not Found\n< �```'
132-
)])
134+
UNABLE_TO_PARSE_RESPONSE_ERROR.format(status_code=404, reason='Not Found', response_body='')
135+
)]
136+
)
133137
def test_get_api_error(response, expected_error, expected_message):
134138
parser = errors._Parser()
135139
with pytest.raises(errors.DatabricksError) as e:
136140
raise parser.get_api_error(response)
137141
assert isinstance(e.value, expected_error)
138142
assert str(e.value) == expected_message
143+
144+

0 commit comments

Comments
 (0)