Originally created by: endernoke
Describe the bug
On some accounts, attempting to start the chat will fail, and an error 'NoneType' object has no attribute 'get' will occur after fetching chat data.
This issue may also appear when running instagram notify, when attempting to fetch the number of unread messages. Basically whatever that tries to fetch direct threads data.
To Reproduce
instagram chat start, instagram chat search <title> or instagram notifyExpected behavior
No bug should occur and user should be able to proceed to chat menu as normal.
Traceback (most relevant parts)
│ │
│ D:\repos\instagram-cli\venv\Lib\site-packages\instagrapi\extractors.py:288 in extract_direct_thread │
│ │
│ 285 │ │ data["messages"].append(extract_direct_message(item)) │
│ 286 │ data["users"] = [extract_user_short(u) for u in data["users"]] │
│ 287 │ if "inviter" in data: │
│ ❱ 288 │ │ data["inviter"] = extract_user_short(data["inviter"]) │
│ 289 │ data["left_users"] = data.get("left_users", []) │
│ 290 │ data["last_activity_at"] = datetime.datetime.fromtimestamp( │
│ 291 │ │ data["last_activity_at"] // 1_000_000 │
│ │
│ ╭────────────────────────────────── locals ──────────────────────────────────╮ │
│ │ data = { │ │
│ │ │ 'has_older': True, │ │
│ │ │ 'has_newer': False, │ │
│ │ │ 'pending': False, │ │
│ │ │ 'inviter': None, │ │
# ...
│ │ │ ... +18 │ │
│ │ } │ │
│ ╰────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ D:\repos\instagram-cli\venv\Lib\site-packages\instagrapi\extractors.py:195 in extract_user_short │
│ │
│ 192 ╭── locals ───╮ │
│ 193 def extract_user_short(data): │ data = None │ │
│ 194 │ """Extract User Short info""" ╰─────────────╯ │
│ ❱ 195 │ data["pk"] = data.get("id", data.get("pk", None)) │
│ 196 │ assert data["pk"], f'User without pk "{data}"' │
│ 197 │ return UserShort(**data) │
│ 198 │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'get'
Versions
Additional context
This may be due to the fact that the user is kicked out of a group chat.
Originally posted by: endernoke
This can simply be fixed by replacing
with
in
instagrapi/extractors.pyThough that means we need to re-wrap a significant amount of instagrapi code.
Originally posted by: endernoke
The issue is addressed in instagrapi's unreleased master branch
Ticket changed by: endernoke
Ticket changed by: endernoke
Ticket changed by: endernoke
Originally posted by: endernoke
PyPI doesn't support adding the instagrapi git repo as a direct dependency, see https://stackoverflow.com/a/54894359, which means we will need to wait for instagrapi 2.1.4 to be released on PyPI before this issue can be fixed.
A temporary workaround is installing instagramCLI manually in the
dependency-fixbranch.Originally posted by: endernoke
Duplicate of [#47]
Related
Tickets:
#47Ticket changed by: endernoke
Originally posted by: endernoke
instagrapi 2.1.5 released