Skip to content

Imapsync task fails when processing subfolders under Public or Shared #8061

Description

@lucagasparini

Description

In some cases, the imapsync task stops because of errors while trying to access or process messages located in subfolders under Public and Shared.

The current default exclusion configured in syncctl is:

--exclude '^Public$|^Shared$'"${exclude_regex}"

However, this only excludes the top-level Public and Shared folders. It does not exclude their subfolders, which may still be processed and cause the task to fail.

Steps to reproduce

  1. Run a syncctl / imapsync task using the default exclusion rule:

    --exclude '^Public$|^Shared$'"${exclude_regex}"
    
  2. Use an IMAP account where Public or Shared contains subfolders, such as:

    Public/Junk
    Shared/estero/Archive/2020
    
  3. Start the synchronization task.

  4. Notice that subfolders under Public and Shared are not excluded and imapsync attempts to process them.

  5. The task may stop with ERR_SELECT / EXIT_ERR_SELECT errors caused by permission, folder creation, or server-side access errors.

Examples from task logs

Example 1:

Err 1/1: Host1 folder Public/Junk: Could not select: 1388 NO [NOPERM] Permission denied (0.001 + 0.000 secs).
The most frequent error is ERR_SELECT.
Exiting with return value 117 (EXIT_ERR_SELECT) 1/50 nb_errors/max_errors PID 3889

Example 2:

Could not create folder [Shared/estero/Archive/2020] from [Shared/estero/Archive/2020]: 218 NO [CANNOT] Mailbox can't be created (0.103 + 0.000 + 0.102 secs).
Err 46/50: Host2 folder Shared/estero/Archive/2020: Could not select: 220 NO [SERVERBUG] Internal error occurred. Refer to server log for more information. [2026-05-19 12:58:35] (0.116 + 0.000 + 0.115 secs).

Current behavior

Subfolders such as the following are not excluded:

Public/Junk
Shared/estero/Archive/2020

As a result, imapsync attempts to select or create these folders and may fail with errors such as:

ERR_SELECT
EXIT_ERR_SELECT
NOPERM Permission denied
CANNOT Mailbox can't be created
SERVERBUG Internal error occurred

Expected behavior

All folders under Public and Shared should be excluded by default, including their subfolders, so that imapsync does not attempt to select, create, or synchronize them.

Suggested fix

Update the default exclusion from:

--exclude '^Public$|^Shared$'"${exclude_regex}"

to:

--exclude '^Shared(/.*)?$|^Public(/.*)?$'"${exclude_regex}"

This would exclude both the top-level folders and all their subfolders, for example:

Shared
Shared/estero
Shared/estero/Archive/2020
Public
Public/Junk

Components

ns8-imapsync

Note:

Ticket Ref: #202736 - #202043

Metadata

Metadata

Assignees

Labels

testingPackages are available from testing repositories

Type

No fields configured for Bug.

Projects

Status
Testing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions