-
Notifications
You must be signed in to change notification settings - Fork 195
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
JSON serialization failing as of today on a handful of different python sdk methods #1410
Comments
I am having the same problem, using looker-sdk==22.16.0 |
My coworker ran into a similar issue running looker-sdk==23.16.0 on python 3.11.5 (error output below). I'm running the same script, with the same looker-sdk version (23.16.0), but on python 3.9.13 and am NOT running into the same issue.
|
There seems to be a breaking change from the cattrs package(a dependancy of looker-sdk) for versions after |
We're getting a similar error with Python 3.11.1, looker-sdk 23.16.0, 4.0 API. Offending code: def disable_users(sdk: mtds.Looker40SDK, user_ids: List[str]) -> None:
"""
Disable a list of users
:param sdk: Looker API SDK object
:param user_ids: List of user IDs
:return: None
"""
for user_id in user_ids:
user = sdk.user(user_id)
assert isinstance(user, mls.User)
assert not user.is_disabled
user.is_disabled = True
sdk.update_user(user_id=user.id, body=user)
assert user.is_disable Stacktrace: Traceback (most recent call last):
File "/workdir/scripts/user_management/user_audit.py", line 201, in <module>
main(
File "/workdir/scripts/user_management/user_audit.py", line 141, in main
user_audit_utils.disable_users(sdk, inactive_user_ids_to_disable)
File "/workdir/scripts/user_management/user_audit_utils.py", line 240, in disable_users
sdk.update_user(user_id=user.id, body=user)
File "/usr/local/lib/python3.11/site-packages/looker_sdk/sdk/api40/methods.py", line 11423, in update_user
self.patch(
File "/usr/local/lib/python3.11/site-packages/looker_sdk/rtl/api_methods.py", line 192, in patch
serialized = self._get_serialized(body)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/looker_sdk/rtl/api_methods.py", line 156, in _get_serialized
serialized = self.serialize(api_model=body) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/looker_sdk/rtl/serialize.py", line 81, in serialize
return json.dumps(data).encode("utf-8") # type: ignore
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type CredentialsGoogle is not JSON serializable |
Downgrading the
|
awesome guys, this worked for me |
|
As stated in issue #1410 , `cattrs` appears to have introduced a breaking change starting in version 23.2.
Closed as fixed. |
Fixes looker-open-source/sdk-codegen#1410 that directly affects Looker ingestions erroring out with: ``` 'looker_sdk.rtl.serialize.DeserializeError'>: Bad json Unterminated string starting at: line 1 column 7721467 " ```
Did something change in the sdk or the API in just the last day? We are on
looker-sdk==23.16.0
and the 4.0 api. As of today we started receiving type errors that objects are not JSON serializable. Is there maybe an easier way to skip the deserialization step that puts these in the SDK models? Do I have to traverse all of the keys/items of the model data and turn them into dicts in order to get the raw data?I even tried using the
serialize
function with the 4.0 converter directly but that got a serialization error datetime:The text was updated successfully, but these errors were encountered: