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] Properly include message when handing SCIM errors #753

Merged
merged 2 commits into from
Sep 10, 2024
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
5 changes: 3 additions & 2 deletions databricks/sdk/errors/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ def parse_error(self, response: requests.Response, response_body: bytes) -> Opti
if detail:
# Handle SCIM error message details
# @see https://tools.ietf.org/html/rfc7644#section-3.7.3
error_args[
'message'] = f"{scim_type} {error_args.get('message', 'SCIM API Internal Error')}".strip(" ")
if detail == "null":
detail = "SCIM API Internal Error"
error_args['message'] = f"{scim_type} {detail}".strip(" ")
error_args['error_code'] = f"SCIM_{status}"
return error_args

Expand Down
11 changes: 10 additions & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,16 @@ def make_private_link_response() -> requests.Response:
'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```')), ])
'< this is not a real response```')),
[
fake_response(
'GET', 404,
json.dumps({
'detail': 'Group with id 1234 is not found',
'status': '404',
'schemas': ['urn:ietf:params:scim:api:messages:2.0:Error']
})), errors.NotFound, 'None Group with id 1234 is not found'
]])
def test_get_api_error(response, expected_error, expected_message):
with pytest.raises(errors.DatabricksError) as e:
raise errors.get_api_error(response)
Expand Down
Loading