Naive and kinda silly workaround:

in `org.apache.james.imap.processor.AbstractMailboxProcessor#messageRange` in case of empty mailbox (`selected.existsCount()`) replace empty optional with actual full range ("1:*"): `Optional.of(MessageRange.range(MessageUid.of(lowVal), MessageUid.of(highVal)))`. Probably rather inefficient as it would make actual retrieval?

PS. Is there a global logger of everything that James returns to the client (no idea what the response is in this case :) )

Wojtek

On 20/08/2024 19:59, Wojtek wrote:
Hi,
So I've been debugging issue with following error being returned when using Evolution on empty mailbox. It requests "UID FETCH 1:*" -- not sure if that's correct (complete log below [1])

It should be handled in `org.apache.james.imap.processor.AbstractMailboxProcessor#messageRange` and it returns `Optional.empty()`, because `selected.existsCount()` returns 0 (SelectedMailbox, empty mailbox?)

On the face of it range `1:*` looks valid but IMAP is quite complex so I wouldn't be surprised if in this case it wasn't.

Any hint how to deal with/fix that error correctly would be appreciated.

Btw. it would be handy if the log would contain complete received command, even for learning/ understanding better what's going on/what was received (for example UID fetch lacks actual parameters)

PS. Surprisingly Thunderbird doesn't trigger the error but looking at the logs it seems that's because TB doesn't send `SELECT` command?


[1] log:

```
[2024-08-20 19:23:07.614] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandTagged(): Got <tag>: Tag{value=F00066} [2024-08-20 19:23:07.614] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandNamed(): Got <command>: SELECT [2024-08-20 19:23:07.624] [DEBUG] [   boundedElastic-16] o.a.j.m.s.StoreMailboxManager.getMailbox(): Loaded mailbox #private:admin@atlantiscity:INBOX [2024-08-20 19:23:07.658] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandTagged(): Got <tag>: Tag{value=F00067} [2024-08-20 19:23:07.658] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandNamed(): Got <command>: IDLE [2024-08-20 19:23:11.211] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandTagged(): Got <tag>: Tag{value=F00068} [2024-08-20 19:23:11.212] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandNamed(): Got <command>: STATUS [2024-08-20 19:23:11.213] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.p.StatusProcessor.lambda$logInitialRequest$8(): Status called on mailbox named #private:admin@atlantiscity:Archive [2024-08-20 19:23:11.219] [DEBUG] [   boundedElastic-16] o.a.j.m.s.StoreMailboxManager.getMailbox(): Loaded mailbox #private:admin@atlantiscity:Archive [2024-08-20 19:23:11.234] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandTagged(): Got <tag>: Tag{value=F00069} [2024-08-20 19:23:11.234] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandNamed(): Got <command>: SELECT [2024-08-20 19:23:11.240] [DEBUG] [   boundedElastic-16] o.a.j.m.s.StoreMailboxManager.getMailbox(): Loaded mailbox #private:admin@atlantiscity:Archive [2024-08-20 19:23:11.274] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandTagged(): Got <tag>: Tag{value=F00070} [2024-08-20 19:23:11.274] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.m.DefaultImapDecoder.decodeCommandNamed(): Got <command>: UID [2024-08-20 19:23:11.274] [DEBUG] [ imapserver-ssl-io-6] o.a.j.i.d.p.UidCommandParser.decode(): Got <command>: UID FETCH [2024-08-20 19:23:11.276] [DEBUG] [   boundedElastic-16] o.a.j.m.s.StoreMailboxManager.lambda$getMailboxReactive$2(): Loaded mailbox 41356 #private:admin@atlantiscity:Archive [2024-08-20 19:23:11.277] [DEBUG] [   boundedElastic-16] o.a.j.i.p.f.FetchProcessor.lambda$processRequestReactive$5(): Fetch failed for mailbox 41356 because of invalid sequence-set [IdRange ( 1->9223372036854775807 )]
org.apache.james.mailbox.exception.MessageRangeException: 1:9223372036854775807 
is an invalid range
     at 
org.apache.james.imap.processor.fetch.FetchProcessor.lambda$doFetch$9(FetchProcessor.java:205)
     Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
     reactor.core.publisher.Mono.flatMap(Mono.java:3171)
     
org.apache.james.imap.processor.fetch.FetchProcessor.processRequestReactive(FetchProcessor.java:162)
Error has been observed at the following site(s):
    *__Mono.flatMap ⇢ at org.apache.james.imap.processor.fetch.FetchProcessor.processRequestReactive(FetchProcessor.java:162)
Original Stack Trace:
        at org.apache.james.imap.processor.fetch.FetchProcessor.lambda$doFetch$9(FetchProcessor.java:205)
         at java.base/java.util.Optional.orElseThrow(Optional.java:403)
         at 
org.apache.james.imap.processor.fetch.FetchProcessor.doFetch(FetchProcessor.java:205)
        at org.apache.james.imap.processor.fetch.FetchProcessor.lambda$processRequestReactive$4(FetchProcessor.java:185)         at com.github.fge.lambdas.functions.FunctionChainer.lambda$sneakyThrow$49(FunctionChainer.java:74)
         at 
reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
         at 
reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
        at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:252)
         at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
         at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/ java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
         at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
         at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
         at java.base/java.lang.Thread.run(Thread.java:1583)
```




---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to