processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.09k stars 1.51k forks source link

XEP-0060 (Publish-Subscribe) incorrect error response if requested item does not exist #2288

Closed horazont closed 6 years ago

horazont commented 6 years ago

What version of ejabberd are you using?

18.01, 17.12 (docker images)

What operating system (version) are you using?

Linux.

How did you install ejabberd (source, package, distribution)?

Docker image from https://hub.docker.com/r/ejabberd/ecs/

What did not work as expected? Are there error messages in the log? What was the unexpected behavior? What was the expected result?

I am doing a simple publish-purge-fetch test to ensure that my client implements it correctly. However, the response from ejabberd when I request the deleted item is incorrect. The item is created like this (XML pretty-printed for readability; C->S means client-to-server, S->C means server-to-client):

C->S: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id="xMyBJuczLpKPJC7uy20oN" type="set">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <publish node="e66f63f6-6f28-4e11-bfb5-a82d628d80c7">
      <item>
        <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test"/>
      </item>
    </publish>
  </pubsub>
</iq>
S->C: <iq xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en" to="60507180122299296582535@localhost/58924481883205941432567" from="pubsub.localhost" type="result" id="xMyBJuczLpKPJC7uy20oN">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <publish node="e66f63f6-6f28-4e11-bfb5-a82d628d80c7">
      <item id="5EEE93D7CFF78"/>
    </publish>
  </pubsub>
</iq>

Then the node is purged:

C->S: <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id="ximZnOPv6mSDMUwKaBOpm" type="set">
  <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
    <purge node="e66f63f6-6f28-4e11-bfb5-a82d628d80c7"/>
  </pubsub>
</iq>
S->C: <iq xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en" to="60507180122299296582535@localhost/58924481883205941432567" from="pubsub.localhost" type="result" id="ximZnOPv6mSDMUwKaBOpm"/>

And the item is requested to check that the purge has worked:

<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id="xK9ZwK/GgGrYdy5LYV7no" type="get">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <items node="e66f63f6-6f28-4e11-bfb5-a82d628d80c7">
      <item id="5EEE93D7CFF78"/>
    </items>
  </pubsub>
</iq>

Now ejabberd unexpectedly replies with an error:

S->C: <iq xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en" to="60507180122299296582535@localhost/58924481883205941432567" from="pubsub.localhost" type="error" id="xK9ZwK/GgGrYdy5LYV7no">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <items node="e66f63f6-6f28-4e11-bfb5-a82d628d80c7">
      <item id="5EEE93D7CFF78"/>
    </items>
  </pubsub>
  <error code="404" type="cancel">
    <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  </error>
</iq>

Which is incorrect according to XEP-0060 §6.5.9.12:

If there are no items at the node or the requested items do not exist, the service SHOULD return an IQ stanza of type "result" with an empty <items/> element.

I would expect ejabberd to reply with an empty <items/> element as it does for a generic items query:

S->C: <iq xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en" to="60507180122299296582535@localhost/58924481883205941432567" from="pubsub.localhost" type="result" id="xK9ZwK/GgGrYdy5LYV7no">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <items node="e66f63f6-6f28-4e11-bfb5-a82d628d80c7"/>
  </pubsub>
</iq>
lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.