[bug] Potentially incorrect date format in last_status_at #637

Open
opened 2023-08-30 10:05:10 +00:00 by nil · 3 comments

Your setup

From source

Extra details

NixOS unstable

Version

3.9.3

PostgreSQL version

14

What were you trying to do?

Retrieve a user’s timeline as part of the NixOS module test (see https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/akkoma.nix#L36) using toot (https://github.com/ihabunek/toot/).

What did you expect to happen?

Get a list of posts.

What actually happened?

Toot chokes on the last_status_at account field, expecting a date (like 2023-08-30), but receiving a date/time without timezone (2023-08-30T11:40:00):

Traceback (most recent call last):
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/bin/.toot-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/console.py", line 961, in main
    run_command(app, user, command_name, args)
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/console.py", line 943, in run_command
    return fn(app, user, parsed_args)
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/commands.py", line 60, in timeline
    statuses = [from_dict(Status, item) for item in items]
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/commands.py", line 60, in <listcomp>
    statuses = [from_dict(Status, item) for item in items]
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 373, in from_dict
    return cls(**dict(_fields()))
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 371, in _fields
    yield field.name, _convert(field_type, value)
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 404, in _convert
    return from_dict(field_type, value)
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 373, in from_dict
    return cls(**dict(_fields()))
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 371, in _fields
    yield field.name, _convert(field_type, value)
  File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 397, in _convert
    return date.fromisoformat(value)
ValueError: Invalid isoformat string: '2023-08-23T08:58:18'

I confirmed that this is triggered by toot expecting a date instead of date/time for the last_status_at field of the account structure: https://github.com/ihabunek/toot/blob/master/toot/entities.py#L64

I am uncertain whether this is an issue in Akkoma, toot, or both.

Mastodon appears to provide a full date/time with decimal fraction and timezone (like 2023-08-30T11:40:00.000Z, see https://docs.joinmastodon.org/methods/statuses/), which would also break toot.

Logs

No response

Severity

I cannot use the software

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup From source ### Extra details NixOS unstable ### Version 3.9.3 ### PostgreSQL version 14 ### What were you trying to do? Retrieve a user’s timeline as part of the NixOS module test (see <https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/akkoma.nix#L36>) using toot (<https://github.com/ihabunek/toot/>). ### What did you expect to happen? Get a list of posts. ### What actually happened? Toot chokes on the `last_status_at` account field, expecting a date (like `2023-08-30`), but receiving a date/time without timezone (`2023-08-30T11:40:00`): ``` Traceback (most recent call last): File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/bin/.toot-wrapped", line 9, in <module> sys.exit(main()) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/console.py", line 961, in main run_command(app, user, command_name, args) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/console.py", line 943, in run_command return fn(app, user, parsed_args) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/commands.py", line 60, in timeline statuses = [from_dict(Status, item) for item in items] File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/commands.py", line 60, in <listcomp> statuses = [from_dict(Status, item) for item in items] File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 373, in from_dict return cls(**dict(_fields())) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 371, in _fields yield field.name, _convert(field_type, value) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 404, in _convert return from_dict(field_type, value) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 373, in from_dict return cls(**dict(_fields())) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 371, in _fields yield field.name, _convert(field_type, value) File "/nix/store/85x1fp77svwvdmbnfpzvn63qpg0vlzbj-toot-0.38.1/lib/python3.10/site-packages/toot/entities.py", line 397, in _convert return date.fromisoformat(value) ValueError: Invalid isoformat string: '2023-08-23T08:58:18' ``` I confirmed that this is triggered by toot expecting a date instead of date/time for the `last_status_at` field of the account structure: <https://github.com/ihabunek/toot/blob/master/toot/entities.py#L64> I am uncertain whether this is an issue in Akkoma, toot, or both. Mastodon appears to provide a full date/time with decimal fraction and timezone (like `2023-08-30T11:40:00.000Z`, see <https://docs.joinmastodon.org/methods/statuses/>), which would also break toot. ### Logs _No response_ ### Severity I cannot use the software ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
nil added the
bug
label 2023-08-30 10:05:10 +00:00
Author
Corresponding toot issue: <https://github.com/ihabunek/toot/issues/399>

Mastodon appears to provide a full date/time

That example is wrong according to their own documentation - Status includes an Account which has last_status_at defined as "String (ISO 8601 Date), or null if no statuses". Akkoma is sending the wrong format and toot appears to be doing the correct thing according to the MastoAPI docs.

> Mastodon appears to provide a full date/time That example is wrong according to their own documentation - `Status` includes an `Account` which has `last_status_at` defined as "String (ISO 8601 Date), or null if no statuses". Akkoma is sending the wrong format and toot appears to be doing the correct thing according to the MastoAPI docs.
Author

Mastodon appears to provide a full date/time

That example is wrong according to their own documentation - Status includes an Account which has last_status_at defined as "String (ISO 8601 Date), or null if no statuses". Akkoma is sending the wrong format and toot appears to be doing the correct thing according to the MastoAPI docs.

That is consistent with the Mastodon code, as far as I can see.

I opened an issue regarding the discrepancy in the documentation: https://github.com/mastodon/mastodon/issues/26843

> > Mastodon appears to provide a full date/time > > That example is wrong according to their own documentation - `Status` includes an `Account` which has `last_status_at` defined as "String (ISO 8601 Date), or null if no statuses". Akkoma is sending the wrong format and toot appears to be doing the correct thing according to the MastoAPI docs. That is consistent with the Mastodon code, as far as I can see. I opened an issue regarding the discrepancy in the documentation: <https://github.com/mastodon/mastodon/issues/26843>
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#637
No description provided.