looker-open-source / sdk-codegen

One SDK to rule them all, and in the codegen bind them
MIT License
234 stars 195 forks source link

`move_look` function error not handled #1476

Open larrybirb opened 4 months ago

larrybirb commented 4 months ago

‎APIMethods._return‎ is not handling errors from ‎Looker40SDK.move_look function. We see a non-useful exception str() failed when the API fails which obscures debugging.

Traceback (most recent call last):
  File "/home/user/shared-tableau-scripts/gcp-perms/looker_api_move_look_production.py", line 23, in <module>
    response = sdk.move_look(id, folder)
  File "/home/user/.local/lib/python3.10/site-packages/looker_sdk/sdk/api40/methods.py", line 7417, in move_look
    self.patch(
  File "/home/user/.local/lib/python3.10/site-packages/looker_sdk/rtl/api_methods.py", line 210, in patch
    return self._return(response, structure)
  File "/home/user/.local/lib/python3.10/site-packages/looker_sdk/rtl/api_methods.py", line 102, in _return
    raise sdk_error
looker_sdk.error.SDKError: <exception str() failed>

The actual API error:

{"message":"Validation Failed","errors":[{"field":"folder_id","code":"already_exists","message":"folder_id and the folder id of the existing look must be different","documentation_url":"
https://cloud.google.com/looker/docs/r/err/4.0/422/patch/looks/:look_id/move"}],"documentation_url":"https://cloud.google.com/looker/docs/r/err/4.0/422/patch/looks/:look_id/move"}
jeremytchang commented 2 months ago

This may be a feature request/enhancement for better error handling in python sdk. We need to investigate.

In the meantime, welcome any contributions or suggestions!