Skip to content

[BUG] DirectMessage's timestamp processing error #2388

@Brickm4n

Description

@Brickm4n

Describe the bug
When I try to get messages from a thread with direct_messages() I get a error, that the datetime is not valid.

To Reproduce
cl=Client()
cl.login(input("Username"),input("Passwd"))
cl.direct_messages(cl.direct_threads()[0].id, 50)

(This only reproduces the problem if there is a old enough message in the last 50 messages)

Traceback
Traceback (most recent call last):
File "/usr/lib/python3.12/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,

File "/usr/lib/python3.12/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/brix/.vscode/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 71, in
cli.main()
File "/home/brix/.vscode/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 508, in main
run()
File "/home/brix/.vscode/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 358, in run_file
runpy.run_path(target, run_name="main")
File "/home/brix/.vscode/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)

File "/home/brix/.vscode/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in _run_module_code
_run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
File "/home/brix/.vscode/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
exec(code, run_globals)
File "./chatget.py", line 55, in
messages=cl.direct_messages(Target.id, i*250)

File "/home/brix/InstaChatBot/Instabot/lib/python3.12/site-packages/instagrapi/mixins/direct.py", line 364, in direct_messages
return self.direct_thread(thread_id, amount).messages

File "/home/brix/InstaChatBot/Instabot/lib/python3.12/site-packages/instagrapi/mixins/direct.py", line 344, in direct_thread
return extract_direct_thread(thread)

File "/home/brix/InstaChatBot/Instabot/lib/python3.12/site-packages/instagrapi/extractors.py", line 285, in extract_direct_thread
data["messages"].append(extract_direct_message(item))

File "/home/brix/InstaChatBot/Instabot/lib/python3.12/site-packages/instagrapi/extractors.py", line 358, in extract_direct_message
data["reply"] = extract_reply_message(data["replied_to_message"])

File "/home/brix/InstaChatBot/Instabot/lib/python3.12/site-packages/instagrapi/extractors.py", line 352, in extract_reply_message
return ReplyMessage(**data)
File "/home/brix/InstaChatBot/Instabot/lib/python3.12/site-packages/pydantic/main.py", line 253, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ReplyMessage
visual_media.expiring_media_action_summary.timestamp
Input should be a valid datetime, dates after 9999 are not supported as unix timestamps [type=datetime_parsing, input_value=1761953663000000, input_type=int]
For further information visit https://errors.pydantic.dev/2.11/v/datetime_parsing

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 21.04]
  • Python version 3.12
  • instagrapi version 2.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions