[GH-ISSUE #2503] Admin->Domains->SomeDomain Internal server error #1612

Closed
opened 2026-02-27 11:18:07 +03:00 by kerem · 0 comments
Owner

Originally created by @angelshtilianov on GitHub (Apr 29, 2022).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/2503

Impacted versions

  • OS Type: Ubuntu
  • OS Version: 20.04
  • Database Type: PostgreSQL
  • Database version: X.y
  • Modoboa: 1.17.0
  • installer used: Yes initially, after that pip upgrade
  • Webserver: Nginx via Apache reverse proxy

Steps to reproduce

Create/edit a domain, and set "Message sending limit" to zero, save/update/
Then go to Admin->Domains->The_Domain_From_Above

Current behavior

Internal server error is generated and the domain is not manageable from web interface.

The problem was tracked down to division by zero in
/srv/modoboa/env/lib/python3.8/site-packages/modoboa/admin/models/mixins.py
And I have fixed it by adding zero check.
def sent_messages_in_percent(self):
"""Return number of sent messages as a percentage."""
if self.message_limit is None:
return None

  •    if (self.message_limit == 0):
    
  •        return 0
      return int(self.sent_messages / float(self.message_limit) * 100)
    

Please someone more familiar with Modoboa to take a look into this fix. I had several cases in the past where I had to delete the domain I've just created, but I didn't debug it back then. I suppose I've been doing the same.

Expected behavior

Should not crash, even there are some glitches.

Originally created by @angelshtilianov on GitHub (Apr 29, 2022). Original GitHub issue: https://github.com/modoboa/modoboa/issues/2503 # Impacted versions * OS Type: Ubuntu * OS Version: 20.04 * Database Type: PostgreSQL * Database version: X.y * Modoboa: 1.17.0 * installer used: Yes initially, after that pip upgrade * Webserver: Nginx via Apache reverse proxy # Steps to reproduce Create/edit a domain, and set "Message sending limit" to zero, save/update/ Then go to Admin->Domains->The_Domain_From_Above # Current behavior Internal server error is generated and the domain is not manageable from web interface. The problem was tracked down to division by zero in /srv/modoboa/env/lib/python3.8/site-packages/modoboa/admin/models/mixins.py And I have fixed it by adding zero check. def sent_messages_in_percent(self): """Return number of sent messages as a percentage.""" if self.message_limit is None: return None + if (self.message_limit == 0): + return 0 return int(self.sent_messages / float(self.message_limit) * 100) Please someone more familiar with Modoboa to take a look into this fix. I had several cases in the past where I had to delete the domain I've just created, but I didn't debug it back then. I suppose I've been doing the same. # Expected behavior Should not crash, even there are some glitches.
kerem 2026-02-27 11:18:07 +03:00
  • closed this issue
  • added the
    bug
    label
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/modoboa-modoboa#1612
No description provided.