zerex290 / sankaku

Asynchronous API wrapper for Sankaku Complex with type-hinting, pydantic data validation and an optional logging support with loguru.
https://zerex290.github.io/sankaku/
MIT License
8 stars 3 forks source link

dev(narugo): is_ai_beta is gone in new API #7

Closed narugo1992 closed 1 year ago

narugo1992 commented 1 year ago

This is the error occurred in the last few hours

Traceback (most recent call last):
  File "test_hair_color.py", line 167, in <module>
    asyncio.run(main(
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "test_hair_color.py", line 35, in main
    await client.login(<hidden>)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/sankaku/clients/clients.py", line 92, in login
    await self._login_via_credentials(login, password)  # type: ignore[arg-type]
  File "/home/ubuntu/.local/lib/python3.8/site-packages/sankaku/clients/clients.py", line 48, in _login_via_credentials
    self._profile = mdl.ExtendedUser(**response.json["current_user"])
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ExtendedUser
is_ai_beta
  field required (type=value_error.missing)

I found that is_ai_beta is gone in the new API. So I move this to the optional arguments.

zerex290 commented 1 year ago

My apologies, I wasn't completely quite right about my last response:

After checking for responses from API endpoints related to users (/users, /auth/token, /users/me) I found out that such json responses don't have attributes show_popup_version, credits, credits_subs, is_ai_beta anymore.

Attribute is_ai_beta gone from all responses completely, but show_popup_version, credits, credits_subs still present in ExtendedUser model (used for logged-in users). Also, response for logged-in users got new field has_mail, which should have been added to ExtendedUser model. And tag and ai post models also got new fields.

So I make changes in library and push new commit, which fixes the problem.