FS#60332 - [pgadmin4] 3.4-1 update bugs out

Attached to Project: Community Packages
Opened by Richard PALO (risto3) - Sunday, 07 October 2018, 06:49 GMT
Last edited by Levente Polyak (anthraxx) - Wednesday, 19 December 2018, 21:29 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Jerome Leclanche (Adys)
Levente Polyak (anthraxx)
Architecture x86_64
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
Upon installing 3.4-1, impossible to connect to [local] server any more.

From the web interface, after entering password, INTERNAL SERVER ERROR
is indicated with the following details:
Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Viewing the log indicates:
2018-10-07 08:47:14,530: ERROR pgadmin: Object type <class 'str'> cannot be passed to C code
Traceback (most recent call last):
File "/usr/lib/pgadmin4/web/pgadmin/browser/server_groups/servers/__init__.py", line 1037, in connect
if password is not None else server.password
File "/usr/lib/pgadmin4/web/pgadmin/utils/crypto.py", line 31, in encrypt
cipher = AES.new(pad(key), AES.MODE_CFB, iv)
File "/usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py", line 206, in new
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
File "/usr/lib/python3.7/site-packages/Crypto/Cipher/__init__.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "/usr/lib/python3.7/site-packages/Crypto/Cipher/_mode_cfb.py", line 230, in _create_cfb_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "/usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py", line 102, in _create_base_cipher
result = start_operation(c_uint8_ptr(key),
File "/usr/lib/python3.7/site-packages/Crypto/Util/_raw_api.py", line 109, in c_uint8_ptr
raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code
2018-10-07 08:47:14,573: ERROR werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/usr/lib/python3.7/site-packages/werkzeug/serving.py", line 258, in execute
application_iter = app(environ, start_response)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/lib/pgadmin4/web/pgadmin/browser/utils.py", line 259, in dispatch_request
return method(*args, **kwargs)
File "/usr/lib/pgadmin4/web/pgadmin/browser/server_groups/servers/__init__.py", line 1040, in connect
return internal_server_error(errormsg=e.message)
AttributeError: 'TypeError' object has no attribute 'message'


Additional info:
* package version(s)
* config and/or log files etc.

$ paclog-pkglist |grep pgad
pgadmin4 3.4-1
phppgadmin 5.1-4

$ uname -a
Linux sarchx64 4.18.12-arch1-1-ARCH #1 SMP PREEMPT Thu Oct 4 01:01:27 UTC 2018 x86_64 GNU/Linux

Steps to reproduce:
update to latest, launch and try to connect to server
This task depends upon

Closed by  Levente Polyak (anthraxx)
Wednesday, 19 December 2018, 21:29 GMT
Reason for closing:  Fixed
Additional comments about closing:  3.6-1
Comment by zunway liang (zunway) - Tuesday, 30 October 2018, 13:09 GMT
I can confirm this problem. It reproduce when you has added a local server and reconnect to it.

Edit:
I found the problem. When I startup pgadmin in shell, it prints PYTHONPATH which has a typo:
Python path: "/usr/lib/pgadmin4/venv/lib/python3.73.7/site-packages:/usr/lib/python3.7/site-packages:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/lib/pgadmin4/venv/lib/python3.7/site-packages"
Python Home: "/usr/lib/pgadmin4/venv"
Webapp path: "/usr/lib/pgadmin4/web/pgAdmin4.py"

The right path is "/usr/lib/pgadmin4/venv/lib/python3.7/site-packages". Strings pgadmin startup execute file also shows that path typo.
Comment by mal (mal) - Saturday, 10 November 2018, 01:50 GMT
I had a slightly different error, with the same result. "Failed to decrypt the saved password. Error: Object type <class 'str'> cannot be passed to C code", and a variant if I tried to enter the password again.
Solution: In the PKGBUILD, reverse the order of lines 27 and 28, to produce:

sed -r 's|(venv/lib/python)|\1'${PYTHONVERSION}'|g' -i runtime/Server.cpp
sed 's|value("PythonPath")|value("PythonPath", "/usr/lib/pgadmin4/venv/lib/python'${PYTHONVERSION}'/site-packages:/usr/lib/python'${PYTHONVERSION}'/site-packages:/usr/lib/python'${PYTHONVERSION}'")|g' -i runtime/{pgAdmin4.cpp,Server.cpp,TrayIcon.cpp}

In the original, it's setting the var (including PYTHONVERSION), then inserting a duplicate PYTHONVERSION.
Comment by Richard PALO (risto3) - Saturday, 10 November 2018, 07:58 GMT
I believe the duplicate problem is tied to the absence of an identifiable terminator...

Try instead
- sed -r 's|(venv/lib/python)|\1'${PYTHONVERSION}'|g' -i runtime/Server.cpp
+ sed -r 's|(venv/lib/python)("\|/)|\1'${PYTHONVERSION}'\2|g' -i runtime/Server.cpp

Also, the python path in runtime/ConfigWindow.ui probably needs to be updated.
This is what is displayed in the Python tab when selecting Configure... from the pgadmin icon.
Comment by Richard PALO (risto3) - Friday, 30 November 2018, 08:16 GMT
Anything in particular holding up applying this last fix?

Loading...