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

[BUG] - Empty userInfo for small accounts #1124

Open
ekorian opened this issue Mar 8, 2024 · 1 comment
Open

[BUG] - Empty userInfo for small accounts #1124

ekorian opened this issue Mar 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ekorian
Copy link
Contributor

ekorian commented Mar 8, 2024

Describe the bug

Certain accounts do not send userInfo, which triggers a KeyError when doing user(username)

{'extra': {'fatal_item_ids': [], 'logid': '20240308185549696ABBB4D8D733706647', 'now': 1709924160000}, 'log_pb': {'impr_id': '20240308185549696ABBB4D8D733706647'}, 'statusCode': 10221, 'status_code': 0, 'status_msg': '', 'userInfo': {}}

The buggy code

The user example with a small account name.

Expected behavior

Probably raise an EmptyResponse exception instead of a KeyError

Error Trace

Put the error trace below if there's any error thrown.

Traceback (most recent call last):
  File "/home/scripts/tiktok/tiktok_api.py", line 204, in <module>
    asyncio.run(scrap_tiktok_users())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/scripts/tiktok/tiktok_api.py", line 175, in scrap_tiktok_users
    users_data = [await user.info() for user in users]
  File "/home/scripts/tiktok/tiktok_api.py", line 175, in <listcomp>
    users_data = [await user.info() for user in users]
  File "/home/.local/lib/python3.10/site-packages/TikTokApi/api/user.py", line 87, in info
    self.__extract_from_data()
  File "/home/.local/lib/python3.10/site-packages/TikTokApi/api/user.py", line 204, in __extract_from_data
    data["userInfo"]["user"]["id"],
KeyError: 'user'

Desktop:

  • OS: Ubuntu 22
  • TikTokApi Version 6.2.1
@ekorian ekorian added the bug Something isn't working label Mar 8, 2024
@Gereks123
Copy link

I seem to have the same issue with one of the accounts I scrape from, the account is totally public and there are no issues regarding some restrictions or something of that nature.

Desktop:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants