Projects tigase _server tigase-mix Issues #33
NPE due to localpart is null (#33)
Closed
wojciech.kapcia@tigase.net opened 2 years ago
[2023-02-03 21:38:43:393] [FINEST  ] [              in_6-mix ] StanzaProcessor.processPacket()  : 1. Packet will be processed by: mix@ip-172-31-38-91.us-west-2.compute.internal, from=s2s@ip-172-31-38-91.us-west-2.compute.internal, to=null, serverAuthorisedStanzaFrom=Optional.empty, DATA=<presence type="unavailable" to="mix.tigase.im/…" from="bot@….com/…" xmlns="jabber:client"><status>Disconnected: unexpected eof while reading</status></presence>, SIZE=191, XMLNS=jabber:client, PRIORITY=PRESENCE, PERMISSION=REMOTE, TYPE=unavailable, STABLE_ID=null
[2023-02-03 21:38:43:393] [SEVERE  ] [              in_6-mix ] StanzaProcessor.processPacket()  : Cannot invoke "String.getBytes(java.nio.charset.Charset)" because the return value of "tigase.xmpp.jid.BareJID.getLocalpart()" is null when processing from=s2s@ip-172-31-38-91.us-west-2.compute.internal, to=null, serverAuthorisedStanzaFrom=Optional.empty, DATA=<presence type="unavailable" to="mix.tigase.im/…" from="bot@….com/…" xmlns="jabber:client"><status>Disconnected: unexpected eof while reading</status></presence>, SIZE=191, XMLNS=jabber:client, PRIORITY=PRESENCE, PERMISSION=REMOTE, TYPE=unavailable, STABLE_ID=null
java.lang.NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because the return value of "tigase.xmpp.jid.BareJID.getLocalpart()" is null
	at tigase.mix.model.DefaultMixLogic.generateTempParticipantId(DefaultMixLogic.java:99)
	at tigase.mix.modules.RoomPresenceModule.leave(RoomPresenceModule.java:317)
	at tigase.mix.modules.RoomPresenceModule.process(RoomPresenceModule.java:158)
	at tigase.component.modules.StanzaProcessor.execute(StanzaProcessor.java:219)
	at tigase.component.modules.StanzaProcessor.process(StanzaProcessor.java:206)
	at tigase.component.modules.StanzaProcessor.processPacket(StanzaProcessor.java:103)
	at tigase.component.AbstractKernelBasedComponent.processPacket(AbstractKernelBasedComponent.java:81)
	at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:191)
	at tigase.pubsub.cluster.PubSubComponentClustered.processPacket(SourceFile:183)
	at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1398)
wojciech.kapcia@tigase.net commented 2 years ago

Complete payload:

[2023-02-03 21:38:43:393] [FINEST  ] [              in_6-mix ] StanzaProcessor.processPacket()  : 1. Packet will be processed by: mix@ip-172-31-38-91.us-west-2.compute.internal, from=s2s@ip-172-31-38-91.us-west-2.compute.internal, to=null, serverAuthorisedStanzaFrom=Optional.empty, DATA=<presence type="unavailable" to="mix.tigase.im/CafetaBot" from="bot@manalejandro.com/DX59dg6ZPDQi" xmlns="jabber:client"><status>Disconnected: unexpected eof while reading</status></presence>, SIZE=191, XMLNS=jabber:client, PRIORITY=PRESENCE, PERMISSION=REMOTE, TYPE=unavailable, STABLE_ID=null
[2023-02-03 21:38:43:393] [SEVERE  ] [              in_6-mix ] StanzaProcessor.processPacket()  : Cannot invoke "String.getBytes(java.nio.charset.Charset)" because the return value of "tigase.xmpp.jid.BareJID.getLocalpart()" is null when processing from=s2s@ip-172-31-38-91.us-west-2.compute.internal, to=null, serverAuthorisedStanzaFrom=Optional.empty, DATA=<presence type="unavailable" to="mix.tigase.im/CafetaBot" from="bot@manalejandro.com/DX59dg6ZPDQi" xmlns="jabber:client"><status>Disconnected: unexpected eof while reading</status></presence>, SIZE=191, XMLNS=jabber:client, PRIORITY=PRESENCE, PERMISSION=REMOTE, TYPE=unavailable, STABLE_ID=null
java.lang.NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because the return value of "tigase.xmpp.jid.BareJID.getLocalpart()" is null
	at tigase.mix.model.DefaultMixLogic.generateTempParticipantId(DefaultMixLogic.java:99)
	at tigase.mix.modules.RoomPresenceModule.leave(RoomPresenceModule.java:317)
	at tigase.mix.modules.RoomPresenceModule.process(RoomPresenceModule.java:158)
	at tigase.component.modules.StanzaProcessor.execute(StanzaProcessor.java:219)
	at tigase.component.modules.StanzaProcessor.process(StanzaProcessor.java:206)
	at tigase.component.modules.StanzaProcessor.processPacket(StanzaProcessor.java:103)
	at tigase.component.AbstractKernelBasedComponent.processPacket(AbstractKernelBasedComponent.java:81)
	at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:191)
	at tigase.pubsub.cluster.PubSubComponentClustered.processPacket(SourceFile:183)
	at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1398)
Andrzej Wójcik (Tigase) commented 2 years ago

The NPE is thrown as it was unexpected to receive presence directed to the component JID with just added resource. Those should only be directed to the channel JID ie. channel-1@mix.tigase.im/CafetaBot. While I can quickly fix NPE, but just checking incoming stanza for having localPart and if missing throwing bad-request, I wonder what was expected from this stanza? is it a bug or is it a valid use case?

@wojtek Should we assume someone wants to "logout" from all rooms and do so? or should we just return bad-request as localPart (required for logout according to XEP-0045) is missing?

wojciech.kapcia@tigase.net commented 2 years ago

Considering https://xmpp.org/extensions/xep-0403.html#usecase-user-offline and https://xmpp.org/extensions/xep-0405.html#usecase-user-presence I would say this is an error on user part (adding mix component to roster). From my understanding of presence in case of MIX (additional capability, not explicit) I would say this is an error and should be treated as such with bad-request.

Andrzej Wójcik (Tigase) commented 2 years ago

Actually, this error was thrown from MUC <-> MIX integration, but even in case of MUC it is not possible to join or leave by sending <presence/> to bare component JID AFAIR.

Andrzej Wójcik (Tigase) commented 2 years ago

I've created a pull request with my changes. Those should fix our problem with presences set to jid without localpart, but I've also included a verification if channel jid always has localpart (as in another case it would trigger NPE anyway). That should at least make it more readable error than plain NPE.

wojciech.kapcia@tigase.net commented 2 years ago

Looks ok, merged

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
Version
tigase-server-8.3.0
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/tigase-mix#33
Please wait...
Page is in error, reload to recover