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

[Fix] Minor fix in error message for generic error #799

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 databricks/sdk/errors/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _unknown_error(response: requests.Response) -> str:
return (
'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 '
f'https://github.com/databricks/databricks-sdk-go/issues. Request log:```{request_log}```')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, nice catch!

f'https://github.com/databricks/databricks-sdk-py/issues. Request log:```{request_log}```')


class _Parser:
Expand Down
20 changes: 11 additions & 9 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def make_private_link_response() -> requests.Response:
subclass_test_cases = [(fake_valid_response('GET', x[0], x[1], 'nope'), x[2], 'nope')
for x in base_subclass_test_cases]

UNABLE_TO_PARSE_RESPONSE_ERROR = (
'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-py/issues. Request log:```GET /api/2.0/service\n'
'< {status_code} {reason}\n< {response_body}```')


@pytest.mark.parametrize(
'response, expected_error, expected_message', subclass_test_cases +
Expand Down Expand Up @@ -112,11 +118,8 @@ def make_private_link_response() -> requests.Response:
(fake_response('GET', 400, '<pre>Worker environment not ready</pre>'), errors.BadRequest,
'Worker environment not ready'),
(fake_response('GET', 400, 'this is not a real response'), errors.BadRequest,
('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'
'< 400 Bad Request\n'
'< this is not a real response```')),
UNABLE_TO_PARSE_RESPONSE_ERROR.format(
status_code=400, reason='Bad Request', response_body='this is not a real response')),
(fake_response(
'GET', 404,
json.dumps({
Expand All @@ -125,11 +128,10 @@ def make_private_link_response() -> requests.Response:
'schemas': ['urn:ietf:params:scim:api:messages:2.0:Error']
})), errors.NotFound, 'None Group with id 1234 is not found'),
(fake_response('GET', 404, json.dumps("This is JSON but not a dictionary")), errors.NotFound,
'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"```'
),
UNABLE_TO_PARSE_RESPONSE_ERROR.format(
status_code=404, reason='Not Found', response_body='"This is JSON but not a dictionary"')),
(fake_raw_response('GET', 404, b'\x80'), errors.NotFound,
'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< �```'
)])
UNABLE_TO_PARSE_RESPONSE_ERROR.format(status_code=404, reason='Not Found', response_body='�'))])
def test_get_api_error(response, expected_error, expected_message):
parser = errors._Parser()
with pytest.raises(errors.DatabricksError) as e:
Expand Down
Loading