1

Topic: Internal server Error when trying to edit user via iRedAdminpro

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9
- Deployed with iRedMail Easy or the downloadable installer? Downloadable installer
- Linux/BSD distribution name and version: Ubuntu 18.04.2 LTS
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL edition
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

When trying to edit a user profile via iRedAdmin-Pro, we are having an "internal server error" message with blank page.

Log from /var/log/syslog
May  3 16:18:37 imail2 uwsgi: 127.0.0.1:7790 [pid: 2763|app: 0|req: 1/4] 127.0.0.1 () {32 vars in 572 bytes} [Fri May  3 16:18:37 2019] GET /api/subscriber/user@mydomain.com/subscribed?query_all_lists=no&email_only=no => generated 31 bytes in 13 msecs (HTTP/1.1 200) 1 headers in 51 bytes (2 switches on core 0)
May  3 16:18:39 imail2 uwsgi: Traceback (most recent call last):#012  File "/usr/lib/python2.7/dist-packages/web/application.py", line 257, in process#012    return self.handle()#012  File "/usr/lib/python2.7/dist-packages/web/application.py", line 248, in handle#012    return self._delegate(fn, self.fvars, args)#012  File "/usr/lib/python2.7/dist-packages/web/application.py", line 488, in _delegate#012    return handle_class(cls)#012  File "/usr/lib/python2.7/dist-packages/web/application.py", line 466, in handle_class#012    return tocall(*args)#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/controllers/sql/user.py", line 477, in GET#012    msg=form.get('msg'),#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/libs/iredbase.py", line 179, in render_template#012    return jinja_env.get_template(template_name).render(context)#012  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 1008, in render#012    return self.environment.handle_exception(exc_info, True)#012  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception#012    reraise(exc_type, exc_value, tb)#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/libs/../templates/default/sql/user/profile.html", line 46, in top-level template code#012    {% from "macros/msg_handlers.html" import user_msg_handler with context %}#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/libs/../templates/default/layout.html", line 192, in top-level template code#012    {% block main %}{% endblock %}#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/libs/../templates/default/sql/user/profile.html", line 509, in block "main"#012    {{ display_random_password(password_length=min_passwd_length,#012  File "/usr/lib/python2.7/dist-packages/jinja2/runtime.py", line 579, in _invoke#012    rv = self._func(*arguments)#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/libs/../templates/default/macros/general.html", line 1914, in template#012    {% set random_password = password_length | generate_random_password %}#012  File "/opt/www/iRedAdmin-Pro-SQL-3.4/libs/iredpwd.py", line 113, in generate_random_password#012    length -= 1#012TypeError: unsupported operand type(s) for -=: 'unicode' and 'int'
May  3 16:18:39 imail2 uwsgi:
May  3 16:18:39 imail2 uwsgi: mail2.domain.com [pid: 2783|app: 2|req: 3/10] 11.11.11.11 () {56 vars in 968 bytes} [Fri May  3 16:18:37 2019] GET /iredadmin/profile/user/general/user@mydomain.com => generated 21 bytes in 1771 msecs (HTTP/1.1 500) 3 headers in 190 bytes (2 switches on core 0)

Email address changed to user@domain.com
Client IP changed to 11.11.11.11

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Internal server Error when trying to edit user via iRedAdminpro

Sorry about this trouble. It's a bug of iRedAdmin-Pro-SQL-3.4 (and iRedAdmin-Pro-LDAP-3.6), patch attached:

diff -r 4f3b27aef05a libs/iredutils.py
--- a/libs/iredutils.py    Tue Apr 30 13:40:09 2019 +0800
+++ b/libs/iredutils.py    Fri May 03 22:26:13 2019 +0700
@@ -1044,15 +1044,21 @@
     except:
         pass
 
-    # Remove unlisted parameters and validate values.
+    # Remove unlisted parameters, invalid values.
+    # Re-format values.
     for (k, v) in _settings.items():
-        if k in setting_kvs_map:
-            _validators = setting_kvs_map[k].get('validators', [])
-            for _validator in _validators:
-                if not _validator(v):
-                    _settings.pop(k)
-        else:
+        if k not in setting_kvs_map:
             _settings.pop(k)
+            continue
+
+        _validators = setting_kvs_map[k].get('validators', [])
+        for _validator in _validators:
+            if not _validator(v):
+                _settings.pop(k)
+                break
+
+            if _validator in [is_integer, is_positive_integer, is_not_negative_integer]:
+                _settings[k] = int(v)
 
     return _settings
 

If you're not familiar with patch, contact us to get a patched version.

3

Re: Internal server Error when trying to edit user via iRedAdminpro

Hi,
Thanks for your prompt response. Can you send me the patched version and confirm the path where to copy the patch.

4

Re: Internal server Error when trying to edit user via iRedAdminpro

Hi,

Please send me the patched version as well.
Thanks!

5

Re: Internal server Error when trying to edit user via iRedAdminpro

Dear @pragpot and @Phyrax,

I can not find your email addresses (used to register forum) in our license database, could you please contact me via email and tell me the license owner or license key? i will send you download link as soon as possible.

Contact us: https://www.iredmail.org/support.html

6 (edited by jauert 2019-05-06 02:42:35)

Re: Internal server Error when trying to edit user via iRedAdminpro

Hello,
I have the same problem. Can you please send me a patched version. My license is still valid.
greeting
Jauert

7

Re: Internal server Error when trying to edit user via iRedAdminpro

Thanks Zhang! I can confirm that this hotfix solved my problem!

8

Re: Internal server Error when trying to edit user via iRedAdminpro

Thanks. The internal server error has been resolved by applying the patched version.

9

Re: Internal server Error when trying to edit user via iRedAdminpro

jauert wrote:

I have the same problem. Can you please send me a patched version. My license is still valid.

Dear Jauert,

Download link sent.

Next time better contact us directly via email so that you can get faster reply: https://www.iredmail.org/contact.html