4
SmarterMail mail folders and with path length limitation
Idea shared by Sébastien Riccio - 4/7/2021 at 1:40 PM
Completed
Hello,

As you probably know, there is a limit on a path length on Windows.

In some conditions, customers using SmarterMail are allowed to create path that exceed this and therefore SmarterMail returns an exception when trying to create the folder on the filesystem.

We identified some possible way customers can do this. For example creating subfolders in subfolders in subfolders that are reaching the limit.
Or moving a subfolder tree in another subfolder tree, creating an even longer subfolder tree.

When this happens the folder is not created on the filesystem, but the reference to the folder IS added to the user folders.json anyway.
The issue is not directly affecting the user account, but if you then issue a domain reload or have to restart SmarterMail because it crashed, these mailbox with such attempted folder creations are unusable.

It need a manual inspection of the folders.json file to remove the entries to these too long folders creation attempt entries.
No action can be done from SmarterMail on these users until the json was cleaned from these. It is really painful.

We absolutely need SmarterMail to prevent adding entries in folders.json for folder it wasn't able to create on the disk.

I was able to reproduce the issue on a test account by creating long names subfolders from an IMAP client and/or moving around folders inside other folders, at some point the account was dead with this in the log:

[2021.04.07] 17:39:55.085 MailboxManager Exception in GetMailbox. Path: dossier pourri\encore plus pourri pour voir &aoa- quel moment &aoc-a bug\et la c'est encore pire qu'avant du coup\apr&aog-s faut voir si &aoc-a fonctionne on sait jamais\la ca va &AOo-tre le truc en trop qui va tout casser Root: G:\SmarterMail\Domains\somedomain.com\Users\madjik\Mail. Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'G:\SmarterMail\Domains\somedomain.com\Users\madjik\Mail\dossier pourri\encore plus pourri pour voir &aoa- quel moment &aoc-a bug\et la c'est encore pire qu'avant du coup\apr&aog-s faut voir si &aoc-a fonctionne on sait jamais\la ca va &AOo-tre le truc en trop qui va tout casser\'.
[2021.04.07] at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
[2021.04.07] at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
[2021.04.07] at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
[2021.04.07] at MailService.Mailboxes.Mailbox.MailboxConstructorFunction()
[2021.04.07] at MailService.Mailboxes.MailboxManager.GetMailbox(String subFolderName, Dictionary`2 timings)
[2021.04.07] 17:40:18.817 MailboxManager Exception in GetMailbox. Path: dossier pourri\encore plus pourri pour voir &aoa- quel moment &aoc-a bug\et la c'est encore pire qu'avant du coup\apr&aog-s faut voir si &aoc-a fonctionne on sait jamais\la ca va &AOo-tre le truc en trop qui va tout casser Root: G:\SmarterMail\Domains\somedomain.com\Users\madjik\Mail. Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'G:\SmarterMail\Domains\somedomain.com\Users\madjik\Mail\dossier pourri\encore plus pourri pour voir &aoa- quel moment &aoc-a bug\et la c'est encore pire qu'avant du coup\apr&aog-s faut voir si &aoc-a fonctionne on sait jamais\la ca va &AOo-tre le truc en trop qui va tout casser\'.
[2021.04.07] at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
[2021.04.07] at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
[2021.04.07] at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
[2021.04.07] at MailService.Mailboxes.Mailbox.MailboxConstructorFunction()
[2021.04.07] at MailService.Mailboxes.MailboxManager.GetMailbox(String subFolderName, Dictionary`2 timings)
[2021.04.07] 17:41:59.086 MailboxManager Exception in GetMailbox. Path: dossier pourri\encore plus pourri pour voir &aoa- quel moment &aoc-a bug\et la c'est encore pire qu'avant du coup\apr&aog-s faut voir si &aoc-a fonctionne on sait jamais\la ca va &AOo-tre le truc en trop qui va tout casser Root: G:\SmarterMail\Domains\somedomain.com\Users\madjik\Mail. Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'G:\SmarterMail\Domains\somedomain.com\Users\madjik\Mail\dossier pourri\encore plus pourri pour voir &aoa- quel moment &aoc-a bug\et la c'est encore pire qu'avant du coup\apr&aog-s faut voir si &aoc-a fonctionne on sait jamais\la ca va &AOo-tre le truc en trop qui va tout casser\'.
[2021.04.07] at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
[2021.04.07] at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
[2021.04.07] at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
[2021.04.07] at MailService.Mailboxes.Mailbox.MailboxConstructorFunction()
[2021.04.07] at MailService.Mailboxes.MailboxManager.GetMailbox(String subFolderName, Dictionary`2 timings)

Another solution could be SmarterMail to allow longer path names when disabling the windows limitation.

As far as I know this can be disabled:
https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

However SmarterMail seems to still apply the limitation (tried after a reboot).

TLDR; It would be great to either support longer path length for mailboxes folders (if it has been enabled on the system) or to prevent too long folder paths to be added in user folders.json for folder that can't be created on the filesystem.

Kind regards


Sébastien Riccio
System & Network Admin

4 Replies

Reply to Thread
4
Matt Petty Replied
Employee Post
I will add this as a bug to our list. An exception coming from the filesystem should stop folders.json from being updated with this info. We've seen issues where folders.json wasn't matching what's on disk and we've had issues reproducing this problem. What you described above is an example of how it can become like this. Thank you for pointing this out.
Matt Petty
Software Developer
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
2
Hello Matt,
Thank you for these informations and taking our request into account.
Kind regards.

Sébastien Riccio
System & Network Admin

1
Matt Petty Replied
Employee Post
This issue is fixed and will be in the next minor. I also noticed that no error was being returned to the web interface when this issue happened. Errors coming from a rename will now also show up as a failure toast message. That way a failure with the rename is clearly evident.

For users with a bad folders.json (in this case) I also made a slight change that was preventing user's from being able to login, we were getting some deep error because of the folder.json issue. With my change these folders will still likely not work however the user will now atleast be able to login to the interface, just clicking on the folders with the issue will now just fail to load the messages. So it may not be as clear that this issue occured for a user, if your worried that user's might be having this issue silently, you can search the general errors log for "Exception in GetMailbox" once you've identified user's with this error visit their mailbox and see if you can see the messages in it, I've noticed there can be some false positives when seeing this error message so definitely verify its actually broken for the user. The steps to repair would involve modifying/removing the data for the broken folders in the folders.json file and restarting the server.
Matt Petty
Software Developer
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
1
Thank you for these details Matt.

I'm currently writing a multi-usage tool for SmarterMail to check some integrity stuff and do some diagnostics. I thought about about a check for this particular issue that would warn about possible path length.
I'll publish the thing on github and here when I consider it mature enough.

Kind regards.
Sébastien Riccio
System & Network Admin

Reply to Thread