patrickfav / rocketchat-exporter

A simple script exporting chats from a rocket chat instance using the public REST API. Useful if no administrative access is possible.
https://favr.dev/opensource/rocketchat-exporter
Apache License 2.0
24 stars 10 forks source link

NoSuchElementException when try to export direct messages #3

Closed 1pedro closed 3 years ago

1pedro commented 4 years ago

Hi guys, i'm exporting rocketchat messages.

Group messages was exported successful Channel messages was exported successful Direct messages get java.lang.RuntimeException: java.util.NoSuchElementException: No value present

patrickfav commented 4 years ago

Do you have a full stack trace maybe? Without it or the test data it'll be hard to pinpoint the exact issue.

1pedro commented 4 years ago

java.lang.RuntimeException: java.util.NoSuchElementException: No value present at at.favre.tools.rocketexporter.cli.Export.run(Export.java:158) at picocli.CommandLine.executeUserObject(CommandLine.java:1729) at picocli.CommandLine.access$900(CommandLine.java:145) at picocli.CommandLine$RunLast.handle(CommandLine.java:2101) at picocli.CommandLine$RunLast.handle(CommandLine.java:2068) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1935) at picocli.CommandLine.execute(CommandLine.java:1864) at at.favre.tools.rocketexporter.cli.Export.main(Export.java:44) Caused by: java.util.NoSuchElementException: No value present at java.base/java.util.Optional.get(Optional.java:141) at at.favre.tools.rocketexporter.RocketExporter$Default.lambda$listDirectMessageChannels$1(RocketExporter.java:209) at java.base/java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:441) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1624) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at at.favre.tools.rocketexporter.RocketExporter$Default.listDirectMessageChannels(RocketExporter.java:210) at at.favre.tools.rocketexporter.cli.Export.run(Export.java:91) ... 7 more

pgrosslicht commented 3 years ago

Hi, the issue arose when trying to export DMs when you had a conversation with yourself in your list of conversations. Those had a list of usernames containing only your username that got filtered out which led to this exception. I pushed a fix for it in #4.