garth.UserProfile.get() and garthUserSettings.get() throw an error
Hi,
Thanks for the package, really useful. I've noticed that when running garth.UserProfile.get() and garth.UserSettings.get() both throw an error during validation with pydantic.
Here's the error for UserProfile. The same happens for UserSettings but with 8 validation errors.
"---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[115], line 1
----> 1 garth.UserProfile.get()
2 #garth.connectapi(\"/userprofile-service/socialProfile\")
3 camel_to_snake_dict(garth.connectapi(\"/userprofile-service/userprofile/user-settings\"))
File /hpcnfs/scratch/DP/amariani/Amariani/Polycomb_regulation/code/puffin/puffin_env/lib/python3.8/site-packages/garth/users/profile.py:80, in UserProfile.get(cls, client)
78 profile = client.connectapi(\"/userprofile-service/socialProfile\")
79 assert isinstance(profile, dict)
---> 80 return cls(**camel_to_snake_dict(profile))
File /hpcnfs/scratch/DP/amariani/Amariani/Polycomb_regulation/code/puffin/puffin_env/lib/python3.8/site-packages/pydantic/_internal/_dataclasses.py:141, in complete_dataclass.<locals>.__init__(__dataclass_self__, *args, **kwargs)
139 __tracebackhide__ = True
140 s = __dataclass_self__
--> 141 s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s)
ValidationError: 1 validation error for UserProfile
profile_image_uuid
Field required [type=missing, input_value=ArgsKwargs((), {'id': 349...: 0, 'user_pro': False}), input_type=ArgsKwargs]
For further information visit https://errors.pydantic.dev/2.8/v/missing"
What works
running directly
garth.connectapi("/userprofile-service/socialProfile")
garth.connectapi("/userprofile-service/userprofile/user-settings")
works. Also, the function camel_to_snake_dict works as intended.
Let me know if you need more info. Thanks again.
Cheers, Andrea
Hi @AndreaMariani-AM - happy to hear you're enjoying using Garth!
It should be a straightforward fix.
Could you create a fork with a branch that has the failing test?
Here's what you have to do:
- Login and save your tokens to the default path
- Run the tests with
make testto make sure they all run - Add a test that fails for your case. This'll record the request and response
- Push the failing test and VCR cassette to your branch
I can then use that to reproduce the issue. Once I can reproduce it with your VCR cassette, the fix should be simple.
Let me know if you need help with the steps above.
What was the resolution?
Hey, sorry i thought i'd posted it.
I still have to figure out exactly what the problem was, but it's definitely on my end. I was running in on a shared server before but locally works just fine. If i'll find more info i'll let you know.
Thanks again, Andrea