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

[ISSUE] Fix 403 deserialization issue in service_principals.get() method #768

Open
kishaningithub opened this issue Sep 18, 2024 · 3 comments
Assignees

Comments

@kishaningithub
Copy link

kishaningithub commented Sep 18, 2024

Description

When calling the service_principals.get() with a valid service principal id the request failed with the following error

Traceback (most recent call last):
  File "/home/test/app/hello.py", line 23, in <module>
    main()
  File "/home/test/app/hello.py", line 18, in main
    details = client.service_principals.get(service_principal.id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/app/.venv/lib/python3.12/site-packages/databricks/sdk/service/iam.py", line 2792, in get
    res = self._api.do('GET', f'/api/2.0/preview/scim/v2/ServicePrincipals/{id}', headers=headers)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/app/.venv/lib/python3.12/site-packages/databricks/sdk/core.py", line 157, in do
    response = retryable(self._perform)(method,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/app/.venv/lib/python3.12/site-packages/databricks/sdk/retries.py", line 54, in wrapper
    raise err
  File "/home/test/app/.venv/lib/python3.12/site-packages/databricks/sdk/retries.py", line 33, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/test/app/.venv/lib/python3.12/site-packages/databricks/sdk/core.py", line 247, in _perform
    raise error from None
databricks.sdk.errors.platform.PermissionDenied: 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/preview/scim/v2/ServicePrincipals/6671074037673577
> * User-Agent: unknown/0.0.0 databricks-sdk-py/0.32.2 python/3.12.6 os/darwin auth/pat
> * Accept-Encoding: gzip, deflate
> * Accept: application/json
> * Connection: keep-alive
> * Authorization: Bearer REDACTED_TOKEN
< 403 Forbidden
< https://<<READACTED>>.cloud.databricks.com/api/2.0/preview/scim/v2/ServicePrincipals/6671074037673577 is only accessible by admins.```

Reproduction
A minimal code sample demonstrating the bug.

import json
from databricks.sdk import WorkspaceClient

def main():
    host = "<<databricks host>>"
    token = "<<token>>"
    client = WorkspaceClient(host=host, token=token)

    id = client.service_principals.list()[0].id
   details = client.service_principals.get(id)
   print(json.dumps(details.as_dict()))

if __name__ == "__main__":
    main()

Expected behavior

  1. The failure "unable to parse response" should not have occurred
  2. The url pointed by the error message should point to this library and not the golang version of the same

Is it a regression?
Did this work in a previous version of the SDK? If so, which versions did you try?
No

Other Information

  • OS: Mac OS
  • Library Version: 0.32.2
@kishaningithub
Copy link
Author

  1. The url pointed by the error message should point to this library and not the golang version of the same

Have fixed the above expected behavior in PR #767

@mgyucht
Copy link
Contributor

mgyucht commented Sep 18, 2024

@kishaningithub please revoke the bearer token you've included in the issue description and remove it from the description when done.

@kishaningithub
Copy link
Author

Done @mgyucht Thanks for the callout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants