-
lovetox
hm after reading the rfc
-
lovetox
if i send an IQ to a server without a "to" attribute
-
MattJ
My favourite topic!
-
lovetox
server needs to treat like my bare jid?
-
lovetox
because the rfc text is a bit cryptic
-
jonas’
lovetox, yes
-
lovetox
ok nice
-
jonas’
but implementations vary :)
-
jonas’
be aware that you might get your IQ back with a @to attribute
-
jonas’
instead of without
-
jonas’
so your reply matchers have to treat @to=localBareJID identical to absent @to
-
jonas’
%s/to/from/g, sorry✎ -
jonas’
%s/@to/@from/g, sorry ✏
-
lovetox
yes, actually i do this very early after stanza parsing
-
lovetox
if there is to or from missing
-
jonas’
:+1:
-
jonas’
then you should be good
-
lovetox
i fill in te respective values the rfc says
-
Ge0rG
and then you have the missing @to in carbons
-
MattJ
My opinion: clients should never use the 'to' attribute of incoming stanzas
-
lovetox
because i simply dont want to deal with absent from / to later in my code
-
MattJ
But I can understand why the missing/different 'from' trips implementations up
-
lovetox
yeah incoming from is obviously important
-
jonas’
MattJ, yes, it was a tpyo✎ -
lovetox
i asked about outgoing to
-
jonas’
MattJ, yes, it was a typo ✏
-
lovetox
because i spares me to always look up my bare jid
-
lovetox
on the various PEP operations
-
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.
-
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.
-
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.
-
flow
Kev, which case is that?
-
Kev
I don't recall, sadly.
-
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,
-
flow
so I am not sure if I would call the behavior you described above a bug
-
lovetox
missing from attribute is allowed
-
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
-
lovetox
and i think thats the case MattJ was thinking about
-
Kev
flow: You might be right. It might be that type=result doesn't mandate that, only type=error.
-
Kev
lovetox: Yes, missing from is definitely allowed.
-
lovetox
i wonder why this was made that way
-
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
-
lovetox
lets save 20 bytes on every 50th message
-
lovetox
but makes it very easy to be tripped up as a developer
-
lovetox
jonas’, im looking again trhough aioxmpp
-
lovetox
and i see you raise an exception when a IQ error is returned
-
lovetox
i guess i look into jabbercat how this looks in a client code
-
lovetox
i had the same thought, for my library, to raise exception
-
lovetox
but i wonder how nice this is for client developers
-
lovetox
especially for iq errors
- eta uses Promises for IQs and just fails the promise
-
lovetox
eta, whats the lib you are writing?
-
eta
lovetox: the component library used by whatsxmpp
-
eta
(which isn't really a fully separate thing yet)
-
lovetox
what language?
-
eta
lovetox: Common Lisp :)
-
eta
relevant code: https://git.theta.eu.org/eta/whatsxmpp/src/branch/master/component.lisp#L258
-
lovetox
yeah never got into Lisp so i probably need a week to even understand a bit of the code
-
eta
reasonable :p
-
lovetox
why i wonder in python about exceptions is
-
lovetox
not on all iq errors you want to simply abort and be finished
-
lovetox
sometimes you expect this case and do other stuff because of the error
-
lovetox
and then you have to do all that in an exception block
-
eta
lovetox: wait is your IQ thing blocking
-
lovetox
which is weird, becuase if it raises again exceptions, then you get this super long traceback
-
eta
like is it synchronous or asynchronous
-
lovetox
while an exception was raised, another exception was raised, and another exception was raised..
-
eta
oh, I guess Python has async/await now, nvm
-
eta
well, this is what multiple return types / Rust's Result type is for
-
eta
like, returning (result, error)
-
lovetox
yeah i do this right now, there is one result, and user can check if it was an error or a normal result
-
lovetox
and can then do his stuff
-
eta
sounds good
-
lovetox
yeah maybe im overthinking this :)
-
lovetox
i guess there is not only one good way
-
eta
especially with exceptions there are two camps
-
moparisthebest
only 2? I'm counting checked exceptions, runtime exceptions, checked+runtime exceptions, and no exceptions :)
-
eta
heh :)
-
jonas’
lovetox, exceptions are amazing for IQ errors
-
jonas’
you can write a chain of IQ calls and wrap it in a single try/except aioxmpp.XMPPError block for example