Menu

#63 Error when starting chat: 'NoneType' object has no attribute 'get'

closed
nobody
bug (44)
2025-06-08
2025-04-20
Anonymous
No

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

  1. Run instagram chat start, instagram chat search <title> or instagram notify
  2. Wait for client to log in
  3. See error

Expected 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

  • instagram--cli: 1.3.1
  • instagrapi: 2.1.3 (latest release)

Additional context
This may be due to the fact that the user is kicked out of a group chat.

Related

Tickets: #64
Tickets: #66

Discussion

  • Anonymous

    Anonymous - 2025-04-20

    Originally posted by: endernoke

    This can simply be fixed by replacing

    if "inviter" in data:
    

    with

    if data.get("inviter):
    

    in instagrapi/extractors.py

    Though that means we need to re-wrap a significant amount of instagrapi code.

     
  • Anonymous

    Anonymous - 2025-04-20

    Originally posted by: endernoke

    The issue is addressed in instagrapi's unreleased master branch

     
  • Anonymous

    Anonymous - 2025-04-20

    Ticket changed by: endernoke

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2025-04-20

    Ticket changed by: endernoke

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2025-04-20

    Ticket changed by: endernoke

    • status: closed --> open
     
  • Anonymous

    Anonymous - 2025-04-20

    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-fix branch.

     
  • Anonymous

    Anonymous - 2025-04-20

    Originally posted by: endernoke

    Duplicate of [#47]

     

    Related

    Tickets: #47

  • Anonymous

    Anonymous - 2025-06-08

    Ticket changed by: endernoke

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2025-06-08

    Originally posted by: endernoke

    instagrapi 2.1.5 released

     

Log in to post a comment.

Auth0 Logo