jdev - 2020-08-05


  1. lovetox

    hm after reading the rfc

  2. lovetox

    if i send an IQ to a server without a "to" attribute

  3. MattJ

    My favourite topic!

  4. lovetox

    server needs to treat like my bare jid?

  5. lovetox

    because the rfc text is a bit cryptic

  6. jonas’

    lovetox, yes

  7. lovetox

    ok nice

  8. jonas’

    but implementations vary :)

  9. jonas’

    be aware that you might get your IQ back with a @to attribute

  10. jonas’

    instead of without

  11. jonas’

    so your reply matchers have to treat @to=localBareJID identical to absent @to

  12. jonas’

    %s/to/from/g, sorry

  13. jonas’

    %s/@to/@from/g, sorry

  14. lovetox

    yes, actually i do this very early after stanza parsing

  15. lovetox

    if there is to or from missing

  16. jonas’

    :+1:

  17. jonas’

    then you should be good

  18. lovetox

    i fill in te respective values the rfc says

  19. Ge0rG

    and then you have the missing @to in carbons

  20. MattJ

    My opinion: clients should never use the 'to' attribute of incoming stanzas

  21. lovetox

    because i simply dont want to deal with absent from / to later in my code

  22. MattJ

    But I can understand why the missing/different 'from' trips implementations up

  23. lovetox

    yeah incoming from is obviously important

  24. jonas’

    MattJ, yes, it was a tpyo

  25. lovetox

    i asked about outgoing to

  26. jonas’

    MattJ, yes, it was a typo

  27. lovetox

    because i spares me to always look up my bare jid

  28. lovetox

    on the various PEP operations

  29. Kev

    I don't have the RFC to hand, but last time I looked it up I decided that if a server stamps a bare JID as the 'from' of a reply to to a stanza that has no 'to', that is not allowed, and therefore a bug.

  30. Kev

    So > But I can understand why the missing/different 'from' trips implementations up Clients are allowed to be tripped up by this, because it's illegal.

  31. Kev

    Although ISTR there is at least one case where, although the server has to treat no to and bare JID as the same, one of the protocols requires that it be no to rather than bare JID for no good reason.

  32. flow

    Kev, which case is that?

  33. Kev

    I don't recall, sadly.

  34. flow

    re the first part: I only cound find the following stanza error rule: 2. The error stanza SHOULD simply swap the 'from' and 'to' addresses from the generated stanza,

  35. flow

    so I am not sure if I would call the behavior you described above a bug

  36. lovetox

    missing from attribute is allowed

  37. lovetox

    When the server generates a stanza from the server for delivery to the client on behalf of the account of the connected client (e.g., in the context of data storage services provided by the server on behalf of the client), the stanza MUST either (a) not include a 'from' attribute or (b) include a 'from' attribute whose value is the account's bare JID

  38. lovetox

    and i think thats the case MattJ was thinking about

  39. Kev

    flow: You might be right. It might be that type=result doesn't mandate that, only type=error.

  40. Kev

    lovetox: Yes, missing from is definitely allowed.

  41. lovetox

    i wonder why this was made that way

  42. lovetox

    it seems really not worth it, its not expected that a big percentage of all traffic is from server to client in a account context

  43. lovetox

    lets save 20 bytes on every 50th message

  44. lovetox

    but makes it very easy to be tripped up as a developer

  45. lovetox

    jonas’, im looking again trhough aioxmpp

  46. lovetox

    and i see you raise an exception when a IQ error is returned

  47. lovetox

    i guess i look into jabbercat how this looks in a client code

  48. lovetox

    i had the same thought, for my library, to raise exception

  49. lovetox

    but i wonder how nice this is for client developers

  50. lovetox

    especially for iq errors

  51. eta uses Promises for IQs and just fails the promise

  52. lovetox

    eta, whats the lib you are writing?

  53. eta

    lovetox: the component library used by whatsxmpp

  54. eta

    (which isn't really a fully separate thing yet)

  55. lovetox

    what language?

  56. eta

    lovetox: Common Lisp :)

  57. eta

    relevant code: https://git.theta.eu.org/eta/whatsxmpp/src/branch/master/component.lisp#L258

  58. lovetox

    yeah never got into Lisp so i probably need a week to even understand a bit of the code

  59. eta

    reasonable :p

  60. lovetox

    why i wonder in python about exceptions is

  61. lovetox

    not on all iq errors you want to simply abort and be finished

  62. lovetox

    sometimes you expect this case and do other stuff because of the error

  63. lovetox

    and then you have to do all that in an exception block

  64. eta

    lovetox: wait is your IQ thing blocking

  65. lovetox

    which is weird, becuase if it raises again exceptions, then you get this super long traceback

  66. eta

    like is it synchronous or asynchronous

  67. lovetox

    while an exception was raised, another exception was raised, and another exception was raised..

  68. eta

    oh, I guess Python has async/await now, nvm

  69. eta

    well, this is what multiple return types / Rust's Result type is for

  70. eta

    like, returning (result, error)

  71. lovetox

    yeah i do this right now, there is one result, and user can check if it was an error or a normal result

  72. lovetox

    and can then do his stuff

  73. eta

    sounds good

  74. lovetox

    yeah maybe im overthinking this :)

  75. lovetox

    i guess there is not only one good way

  76. eta

    especially with exceptions there are two camps

  77. moparisthebest

    only 2? I'm counting checked exceptions, runtime exceptions, checked+runtime exceptions, and no exceptions :)

  78. eta

    heh :)

  79. jonas’

    lovetox, exceptions are amazing for IQ errors

  80. jonas’

    you can write a chain of IQ calls and wrap it in a single try/except aioxmpp.XMPPError block for example