I had a similar issue with a quite big inbox with lots of nested folders. I wanted to go for the solution @unhammer provided but I had a hard time finding the problematic message. (grepping UID didn't help because I had tons of e-mails with the same UID). What I did was to note the number of the problematic box.
C: 0/1 B: 133/162 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0
Maildir error: UID 22 is beyond highest assigned
Then I ran with verbose option mbsync -V mymailchannel
. The verbose option outputs so much information quite quickly. But I knew where to stop, so I stopped when we passed the number 133. (Of course, you can write it to a file and just grep it with the few lines above).
And there was my problematic folder:
C: 0/1 B: 133/262 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0
Opening master box INBOX/my_folder/2020/my_other_folder...
Opening slave box INBOX/my_folder/2020/my_other_folder...
Loading master...
Loading slave...
Maildir error: UID 22 is beyond highest assigned UID 21.
And stipped off everything from ,U=22
in my problematic file as @unhammer suggested and my problem was fixed.