[GH-ISSUE #1522] 🐛 [Bug] Sieve issues #677

Open
opened 2026-02-25 21:35:39 +03:00 by kerem · 12 comments
Owner

Originally created by @knightsg on GitHub (May 22, 2025).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/1522

Originally assigned to: @Shadow243 on GitHub.

🐛 Bug

I've found a couple of issues while trying to make use of the sieve filters. Specifically:

  1. Visiting the "unread" page produces an error popup sieve: invalid config host.
  2. On the Settings -> Filters page, clicking the edit icon (pencil) results in the following:
    a. A grey bar briefly flashes across the top of the browser window but otherwise there is no activity.
    b. The cypht container log emits an error:
NOTICE: PHP message: Session after: Array
(
)
  1. Clicking the enable/disable slider to disable the filter moves the slider to the left so it appears off. However, once the page is reloaded the slider is set to "enabled" again. This also produces the same NOTICE output as above.
  2. Sieve filters don't appear to be working. I created a filter using "Add Filter" in Cypht to move emails from gmail.com (header :contains "From" ["gmail.com"]) to the archive folder and sent a test email from a gmail account but it wasn't moved to archive. I double checked in my dovecot installation's sieve filters folder for the IMAP account I'm logged into in Cypht and it has the following config in a file with the filter name I entered when creating it:
# CYPHT CONFIG HEADER - DON'T REMOVE
# W3siY29uZGl0aW9uIjoiZnJvbSIsInR5cGUiOiJDb250YWlucyIsImV4dHJhX29wdGlvbl92YWx1ZSI6IiIsInZhbHVlIjoiZ21haWwuY29tIn1d
# W3siYWN0aW9uIjoibW92ZSIsInZhbHVlIjoiQXJjaGl2ZSIsImV4dHJhX29wdGlvbl92YWx1ZSI6IiJ9XQ==

# Requirements
require ["fileinto"];

# CYPHT GENERATED CONDITION
if header :contains "From" ["gmail.com"] {
        fileinto "Archive";

}

I suspect this is probably an issue with my dovecot setup and will investigate further on my own but I thought it didn't hurt to mention it here.

On a side note, I just happened to notice the interface is showing "NaN" next to the inbox icon, as shown in this screenshot. It doesn't appear to be causing any issues though.

Version & Environment

Rev: cypht/cypht:daily (0657ed241d29)
OS: Ubuntu 24.04.2 LTS (docker-ce 28.1.1-1~ubuntu.24.04~noble)

Originally created by @knightsg on GitHub (May 22, 2025). Original GitHub issue: https://github.com/cypht-org/cypht/issues/1522 Originally assigned to: @Shadow243 on GitHub. ## 🐛 Bug I've found a couple of issues while trying to make use of the sieve filters. Specifically: 1. Visiting the "unread" page produces an error popup `sieve: invalid config host`. 2. On the Settings -> Filters page, clicking the edit icon (pencil) results in the following: a. A grey bar briefly flashes across the top of the browser window but otherwise there is no activity. b. The cypht container log emits an error: ``` NOTICE: PHP message: Session after: Array ( ) ``` 3. Clicking the enable/disable slider to disable the filter moves the slider to the left so it appears off. However, once the page is reloaded the slider is set to "enabled" again. This also produces the same `NOTICE` output as above. 4. Sieve filters don't appear to be working. I created a filter using "Add Filter" in Cypht to move emails from gmail.com (`header :contains "From" ["gmail.com"]`) to the archive folder and sent a test email from a gmail account but it wasn't moved to archive. I double checked in my dovecot installation's sieve filters folder for the IMAP account I'm logged into in Cypht and it has the following config in a file with the filter name I entered when creating it: ``` # CYPHT CONFIG HEADER - DON'T REMOVE # W3siY29uZGl0aW9uIjoiZnJvbSIsInR5cGUiOiJDb250YWlucyIsImV4dHJhX29wdGlvbl92YWx1ZSI6IiIsInZhbHVlIjoiZ21haWwuY29tIn1d # W3siYWN0aW9uIjoibW92ZSIsInZhbHVlIjoiQXJjaGl2ZSIsImV4dHJhX29wdGlvbl92YWx1ZSI6IiJ9XQ== # Requirements require ["fileinto"]; # CYPHT GENERATED CONDITION if header :contains "From" ["gmail.com"] { fileinto "Archive"; } ``` I suspect this is probably an issue with my dovecot setup and will investigate further on my own but I thought it didn't hurt to mention it here. On a side note, I just happened to notice the interface is showing "NaN" next to the inbox icon, as shown in this [screenshot](https://ibb.co/xq1syfPz). It doesn't appear to be causing any issues though. ### Version & Environment Rev: `cypht/cypht:daily (0657ed241d29)` OS: `Ubuntu 24.04.2 LTS (docker-ce 28.1.1-1~ubuntu.24.04~noble)`
Author
Owner

@knightsg commented on GitHub (May 22, 2025):

Update regarding the Inbox unread count I mentioned above, I just noticed after reading through my remaining unread emails (via the "Unread" page) the inbox now shows -3, the same amount of emails I had just read. Screenshot here: https://ibb.co/hR0Q25ZM.

<!-- gh-comment-id:2902551518 --> @knightsg commented on GitHub (May 22, 2025): Update regarding the Inbox unread count I mentioned above, I just noticed after reading through my remaining unread emails (via the "Unread" page) the inbox now shows `-3`, the same amount of emails I had just read. Screenshot here: https://ibb.co/hR0Q25ZM.
Author
Owner

@Shadow243 commented on GitHub (May 23, 2025):

@knightsg thank you for reporting this issue.

We are currently working on resolving several errors, including the one related to the Sieve filter.
We'll carefully review the entire list you provided to ensure that all reported problems are properly addressed.

We appreciate your detailed feedback — it’s very helpful.

<!-- gh-comment-id:2906033133 --> @Shadow243 commented on GitHub (May 23, 2025): @knightsg thank you for reporting this issue. We are currently working on resolving several errors, including the one related to the Sieve filter. We'll carefully review the entire list you provided to ensure that all reported problems are properly addressed. We appreciate your detailed feedback — it’s very helpful.
Author
Owner

@knightsg commented on GitHub (May 24, 2025):

Thanks, I appreciate the response. Let me know if you need any additional information and I'll do my best to gather it. Do you know at this point if the filter not actually working (filtering emails) is an issue with the filter config Cypht is generating, or would it be likely to be something with my mailserver config? I assumed it was the latter but if you have any reason to think it's due to Cypht itself that would be great to know before I spend more time investigating on my side.

<!-- gh-comment-id:2906450589 --> @knightsg commented on GitHub (May 24, 2025): Thanks, I appreciate the response. Let me know if you need any additional information and I'll do my best to gather it. Do you know at this point if the filter not actually working (filtering emails) is an issue with the filter config Cypht is generating, or would it be likely to be something with my mailserver config? I assumed it was the latter but if you have any reason to think it's due to Cypht itself that would be great to know before I spend more time investigating on my side.
Author
Owner

@knightsg commented on GitHub (May 24, 2025):

Turns out I worked out what was going on with my filter issue almost immediately. I'm using docker-mailserver and after looking at their docs I found that I was missing a symlink /var/mail/<my-mail-domain>/<user>/home/.dovecot.sieve pointing to /var/mail/<my-mail-domain>/<user>/home/sieve/main_script.sieve. I created that symlink and tried sending another test email but it still wasn't filtered.

Then, when I checked the mailserver log it pointed me to the sieve log where I found this error:

sieve: info: started log at 2025-05-24 05:34:51 +0000.
main_script: line 3: error: included personal script 'blocked_senders' does not exist.
main_script: error: validation failed.

I've never set up a filter called blocked_senders before so I investigated and it seems like it's something that Cypht is creating (or is supposed to create). The code seems to point to it: https://github.com/search?q=repo%3Acypht-org%2Fcypht%20blocked_senders&type=code. Anyway, I removed the problematic include line, tested again and that seemed to fix my filter issue 🎉

<!-- gh-comment-id:2906470067 --> @knightsg commented on GitHub (May 24, 2025): Turns out I worked out what was going on with my filter issue almost immediately. I'm using [docker-mailserver](https://github.com/docker-mailserver/docker-mailserver) and after looking at their docs I found that I was missing a symlink `/var/mail/<my-mail-domain>/<user>/home/.dovecot.sieve` pointing to `/var/mail/<my-mail-domain>/<user>/home/sieve/main_script.sieve`. I created that symlink and tried sending another test email but it still wasn't filtered. Then, when I checked the mailserver log it pointed me to the sieve log where I found this error: ``` sieve: info: started log at 2025-05-24 05:34:51 +0000. main_script: line 3: error: included personal script 'blocked_senders' does not exist. main_script: error: validation failed. ``` I've never set up a filter called `blocked_senders` before so I investigated and it seems like it's something that Cypht is creating (or is supposed to create). The code seems to point to it: https://github.com/search?q=repo%3Acypht-org%2Fcypht%20blocked_senders&type=code. Anyway, I removed the problematic `include` line, tested again and that seemed to fix my filter issue 🎉
Author
Owner

@knightsg commented on GitHub (May 24, 2025):

I'll also mention that I've never used the "block sender" option in Cypht so I shouldn't have directly triggered Cypht to add that line in the first place, although looking at the Cypht code very briefly I think it might just add the line automatically. I wonder if perhaps because of my previous issues using the filter editor (see #671) it added the line at some point but failed before it got the chance to create the blocked_senders file?

<!-- gh-comment-id:2906473615 --> @knightsg commented on GitHub (May 24, 2025): I'll also mention that I've never used the "block sender" option in Cypht so I shouldn't have directly triggered Cypht to add that line in the first place, although looking at the Cypht code very briefly I think it might just add the line automatically. I wonder if perhaps because of my previous issues using the filter editor (see #671) it added the line at some point but failed before it got the chance to create the blocked_senders file?
Author
Owner

@knightsg commented on GitHub (May 24, 2025):

All right, sorry for all the comments but I kept digging into this and found more. I created another filter using the editor and once I saved it I checked the main_script.sieve file again and found that it had readded the include :personal "blocked_senders"; line again, but it also hadn't created the associated file even though everything finished processing properly on the Cypht side, at least as far as I can tell.

I'll leave it there for now but I hope this has been of help 🙂

<!-- gh-comment-id:2906476223 --> @knightsg commented on GitHub (May 24, 2025): All right, sorry for all the comments but I kept digging into this and found more. I created another filter using the editor and once I saved it I checked the main_script.sieve file again and found that it had readded the `include :personal "blocked_senders";` line again, but it also hadn't created the associated file even though everything finished processing properly on the Cypht side, at least as far as I can tell. I'll leave it there for now but I hope this has been of help 🙂
Author
Owner

@knightsg commented on GitHub (May 25, 2025):

I came across another issue that appears to be sieve-related. While trying to delete a folder I get the following cypht log error:

mailserver      | 2025-05-25T06:25:26.330557+00:00 mail dovecot: imap-login: Login: user=<email@example.com>, 
method=PLAIN, rip=172.18.0.2, lip=172.18.0.5, mpid=2165, TLS, session=<bAii5e81YtisEgAC>                      
cypht-1         | NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function get_sieve_
client_factory() in /usr/local/share/cypht/modules/imap_folders/modules.php:840                               
cypht-1         | Stack trace:                                                                                
cypht-1         | #0 /usr/local/share/cypht/modules/imap_folders/modules.php(867): get_sieve_linked_mailbox() 
cypht-1         | #1 /usr/local/share/cypht/modules/imap_folders/modules.php(267): is_mailbox_linked_with_filt
ers()                                                                                                         
cypht-1         | #2 /usr/local/share/cypht/lib/modules_exec.php(177): Hm_Handler_process_folder_delete->proce
ss()                                                                                                          
cypht-1         | #3 /usr/local/share/cypht/lib/modules_exec.php(155): Hm_Module_Exec->run_handler_module()   
cypht-1         | #4 /usr/local/share/cypht/lib/dispatch.php(218): Hm_Module_Exec->run_handler_modules()      
cypht-1         | #5 /usr/local/share/cypht/lib/dispatch.php(188): Hm_Dispatch->process_request()             
cypht-1         | #6 /usr/local/share/cypht/site/index.php(54): Hm_Dispatch->__construct()
cypht-1         | #7 {main}
cypht-1         |   thrown in /usr/local/share/cypht/modules/imap_folders/modules.php on line 840
cypht-1         | 127.0.0.1 -  25/May/2025:06:25:26 +0000 "POST /index.php" 500
cypht-1         | 172.18.0.3 - - [25/May/2025:06:25:26 +0000] "POST /?page=folders&imap_server_id=6832b52e224e
5 HTTP/1.0" 500 0 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0"

Also, as I tried deleting the folder a couple more times I noticed that the UI kept adding extra delete confirmation buttons on each attempt, as shown in this screenshot of my third attempt to delete the same folder.

<!-- gh-comment-id:2907643083 --> @knightsg commented on GitHub (May 25, 2025): I came across another issue that appears to be sieve-related. While trying to delete a folder I get the following cypht log error: ``` mailserver | 2025-05-25T06:25:26.330557+00:00 mail dovecot: imap-login: Login: user=<email@example.com>, method=PLAIN, rip=172.18.0.2, lip=172.18.0.5, mpid=2165, TLS, session=<bAii5e81YtisEgAC> cypht-1 | NOTICE: PHP message: PHP Fatal error: Uncaught Error: Call to undefined function get_sieve_ client_factory() in /usr/local/share/cypht/modules/imap_folders/modules.php:840 cypht-1 | Stack trace: cypht-1 | #0 /usr/local/share/cypht/modules/imap_folders/modules.php(867): get_sieve_linked_mailbox() cypht-1 | #1 /usr/local/share/cypht/modules/imap_folders/modules.php(267): is_mailbox_linked_with_filt ers() cypht-1 | #2 /usr/local/share/cypht/lib/modules_exec.php(177): Hm_Handler_process_folder_delete->proce ss() cypht-1 | #3 /usr/local/share/cypht/lib/modules_exec.php(155): Hm_Module_Exec->run_handler_module() cypht-1 | #4 /usr/local/share/cypht/lib/dispatch.php(218): Hm_Module_Exec->run_handler_modules() cypht-1 | #5 /usr/local/share/cypht/lib/dispatch.php(188): Hm_Dispatch->process_request() cypht-1 | #6 /usr/local/share/cypht/site/index.php(54): Hm_Dispatch->__construct() cypht-1 | #7 {main} cypht-1 | thrown in /usr/local/share/cypht/modules/imap_folders/modules.php on line 840 cypht-1 | 127.0.0.1 - 25/May/2025:06:25:26 +0000 "POST /index.php" 500 cypht-1 | 172.18.0.3 - - [25/May/2025:06:25:26 +0000] "POST /?page=folders&imap_server_id=6832b52e224e 5 HTTP/1.0" 500 0 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0" ``` Also, as I tried deleting the folder a couple more times I noticed that the UI kept adding extra delete confirmation buttons on each attempt, as shown in this [screenshot](https://ibb.co/fGFXp6h9) of my third attempt to delete the same folder.
Author
Owner

@Shadow243 commented on GitHub (Jun 25, 2025):

@knightsg I am currently testing and reproducing these errors in order to fix them. All other PRs related to Sieve are now on the master branch. I’ll get back to you shortly for confirmation.

<!-- gh-comment-id:3004212944 --> @Shadow243 commented on GitHub (Jun 25, 2025): @knightsg I am currently testing and reproducing these errors in order to fix them. All other PRs related to Sieve are now on the master branch. I’ll get back to you shortly for confirmation.
Author
Owner

@Shadow243 commented on GitHub (Jun 25, 2025):

Update regarding the Inbox unread count I mentioned above, I just noticed after reading through my remaining unread emails (via the "Unread" page) the inbox now shows -3, the same amount of emails I had just read. Screenshot here: https://ibb.co/hR0Q25ZM.

I was able to reproduce this behavior. Cypht relies heavily on a caching mechanism for performance reasons. When navigating to the "Unread" page, the unread count displayed initially may be stale, as it's served from the cache. However, shortly after page load, Cypht triggers an asynchronous backend request to re-fetch the actual unread count. Once the response is received, the UI updates with the correct number. This brief discrepancy is expected behavior due to the asynchronous cache refresh process.

<!-- gh-comment-id:3004356170 --> @Shadow243 commented on GitHub (Jun 25, 2025): > Update regarding the Inbox unread count I mentioned above, I just noticed after reading through my remaining unread emails (via the "Unread" page) the inbox now shows `-3`, the same amount of emails I had just read. Screenshot here: https://ibb.co/hR0Q25ZM. I was able to reproduce this behavior. Cypht relies heavily on a caching mechanism for performance reasons. When navigating to the "Unread" page, the unread count displayed initially may be stale, as it's served from the cache. However, shortly after page load, Cypht triggers an asynchronous backend request to re-fetch the actual unread count. Once the response is received, the UI updates with the correct number. This brief discrepancy is expected behavior due to the asynchronous cache refresh process.
Author
Owner

@Shadow243 commented on GitHub (Jun 25, 2025):

Update regarding the Inbox unread count I mentioned above, I just noticed after reading through my remaining unread emails (via the "Unread" page) the inbox now shows -3, the same amount of emails I had just read. Screenshot here: https://ibb.co/hR0Q25ZM.

I was able to reproduce this behavior. Cypht relies heavily on a caching mechanism for performance reasons. When navigating to the "Unread" page, the unread count displayed initially may be stale, as it's served from the cache. However, shortly after page load, Cypht triggers an asynchronous backend request to re-fetch the actual unread count. Once the response is received, the UI updates with the correct number. This brief discrepancy is expected behavior due to the asynchronous cache refresh process.

That said, we've noticed that the unread count for the Inbox specifically is not functioning correctly in some cases. A fix will be addressed soon to resolve this issue. Thanks for pointing it out.

<!-- gh-comment-id:3004393704 --> @Shadow243 commented on GitHub (Jun 25, 2025): > > Update regarding the Inbox unread count I mentioned above, I just noticed after reading through my remaining unread emails (via the "Unread" page) the inbox now shows `-3`, the same amount of emails I had just read. Screenshot here: https://ibb.co/hR0Q25ZM. > > I was able to reproduce this behavior. Cypht relies heavily on a caching mechanism for performance reasons. When navigating to the "Unread" page, the unread count displayed initially may be stale, as it's served from the cache. However, shortly after page load, Cypht triggers an asynchronous backend request to re-fetch the actual unread count. Once the response is received, the UI updates with the correct number. This brief discrepancy is expected behavior due to the asynchronous cache refresh process. That said, we've noticed that the unread count for the Inbox specifically is not functioning correctly in some cases. A fix will be addressed soon to resolve this issue. Thanks for pointing it out.
Author
Owner

@marclaporte commented on GitHub (Sep 1, 2025):

A fix will be addressed soon to resolve this issue.

@Shadow243 Any good news? :-)

<!-- gh-comment-id:3240649031 --> @marclaporte commented on GitHub (Sep 1, 2025): > A fix will be addressed soon to resolve this issue. @Shadow243 Any good news? :-)
Author
Owner

@marclaporte commented on GitHub (Jan 20, 2026):

@Shadow243

2.6.0 has been released. We need you :-)

<!-- gh-comment-id:3772611315 --> @marclaporte commented on GitHub (Jan 20, 2026): @Shadow243 2.6.0 has been released. We need you :-)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#677
No description provided.