Shinmera / tooter

A Common Lisp client library for Mastodon instances.
https://shinmera.github.io/tooter
zlib License
44 stars 6 forks source link

status id parsed to integer #4

Closed cage2 closed 4 years ago

cage2 commented 4 years ago

Hi!

As far as i can understand this library is parsing a status id to integer:

https://github.com/Shinmera/tooter/blob/master/objects.lisp#L259

but according to API documentation there is no guarantees that the parsing will not fail:

https://docs.joinmastodon.org/entities/status/

https://docs.joinmastodon.org/client/guidelines/

I wonder if would be better to change the decoding function to identity.

Bye! C.

defaultxr commented 4 years ago

I swapped it to read-from-string personally and it seemed to work fine, though I didn't test it much. Thinking about it now, identity would probably make more sense if it's already read as a string.

The use of parse-integer was causing errors to occur when using tooter with an account on my Pleroma instance.

Shinmera commented 4 years ago

read-from-string is most definitely the wrong thing to do if the ID can be an arbitrary string. intern probably is also the wrong thing, so I suppose it'll have to be raw strings.

cage2 commented 4 years ago

On Thu, Feb 13, 2020 at 01:11:18PM -0800, Nicolas Hafner wrote:

Hello to everyone! :)

read-from-string is most definitely the wrong thing to do if the ID can be an arbitrary string. intern probably is also the wrong thing, so I suppose it'll have to be raw strings.

Honest question: is the same 'intern' problem also in the translator 'to-keyword'?

https://github.com/Shinmera/tooter/blob/master/objects.lisp#L88

https://github.com/Shinmera/tooter/blob/d9923dedf490f343b85180f2bc15896ca0883493/toolkit.lisp#L40

Bye! C.

Shinmera commented 4 years ago

Please test with the latest b4d0494 patch.

Shinmera commented 4 years ago

The kind field is less problematic since it is specified what values it should be able to take. But sure, technically the correct thing to do would be to test more defensively on a case-by-case basis.

cage2 commented 4 years ago

On Thu, Feb 13, 2020 at 01:30:29PM -0800, Nicolas Hafner wrote:

The kind field is less problematic since it is specified what values it should be able to take.

Right, good point! I think it is OK to assume some level of trust with the server where the user have an account.

Bye! C.

cage2 commented 4 years ago

On Thu, Feb 13, 2020 at 01:29:08PM -0800, Nicolas Hafner wrote:

Please test with the latest b4d0494 patch.

Sure! I think i am going, in the next days, to test downloading and parsing timelines from a server.

I also hope to contribute to this library too! :)

Thank you again! C.