Skip to content

Commit

Permalink
Fix SCIM error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mgyucht committed Sep 10, 2024
1 parent c532de6 commit 2437581
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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
9 changes: 8 additions & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ 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

0 comments on commit 2437581

Please sign in to comment.