Ahaaa, I've found out what caused the problem in my case. My muttrc contained a non-existent mailbox in my list of mailboxes. Removing this resolved the problem, i.e. the jsp mailbox in the example below no longer existed:
# Line that was failing
mailboxes +INBOX +"Junk-Email" +jsp
# Line that now works okay
mailboxes +INBOX +"Junk-Email"
Ahaaa, I've found out what caused the problem in my case. My muttrc contained a non-existent mailbox in my list of mailboxes. Removing this resolved the problem, i.e. the jsp mailbox in the example below no longer existed:
# Line that was failing
mailboxes +INBOX +"Junk-Email" +jsp
# Line that now works okay
mailboxes +INBOX +"Junk-Email"